#P8651. Ambiguous Historical Date Interpretation

    ID: 21817 Type: Default 1000ms 256MiB

Ambiguous Historical Date Interpretation

Ambiguous Historical Date Interpretation

In historical documents, dates are recorded in various ambiguous formats. Each date is given as a two‐digit number for each component, separated by a slash ("/"), and the original four-digit year is recorded only by its last two digits. The valid full dates are between \(1960\text{-}01\text{-}01\) and \(2059\text{-}12\text{-}31\).

There are three possible formats for a date string \(A/B/C\):

  • Format 1 (Year/Month/Day): \(y = A,\ m = B,\ d = C\).
  • Format 2 (Month/Day/Year): \(y = C,\ m = A,\ d = B\).
  • Format 3 (Day/Month/Year): \(y = C,\ m = B,\ d = A\).

When converting the two-digit year \(Y\) to a full four-digit year, use the rule:

[ \text{full year} = \begin{cases} 1900+Y, & \text{if } Y \ge 60, \ 2000+Y, & \text{if } Y < 60. \end{cases} ]

Your task is to output all possible valid interpretations of the given ambiguous date string in the format YYYY-MM-DD, each on a new line. The output dates should be unique and sorted in ascending order.

inputFormat

The input consists of a single line containing a date in the format A/B/C, where A, B, and C are two-digit numbers (with possible leading zeros).

outputFormat

Output all valid interpretations of the date, one per line, in the format YYYY-MM-DD (e.g. 2002-03-04). If there are multiple interpretations, output them in ascending order.

sample

02/03/04
2002-03-04

2004-02-03 2004-03-02

</p>