Chronicle
InterviewTime limit2sMemory limit512 MB
Given three two-digit numbers from a disk, list every valid 21st-century date dd/mm/yy that uses the three numbers in some order, or report none.
- Level
Medium4 of 10
- Topics
- Implementation, Brute force, Math, Simulation
- Solved
- No attempts yet
Problem
For several years, scientists in Berland have been excavating the ruins of an ancient civilization that existed centuries before Berland and its neighbors were founded and that, according to indirect evidence, reached an incredibly high level of technology.
Recently, archaeologists found a strange object, presumably a chronicle of certain events, which may reveal to Berland's historians the reason such a powerful society disappeared: a stack of twelve shiny thin disks made of an unknown material, threaded onto a diamond rod. On the top disk, the scientists found three numbers, each consisting of two digits. The scientists guessed that the disk records the date of the end of the great civilization.
After analyzing the disks, they determined that the disks were used in the 21st century according to the calendar used by the ancient civilization, the so-called <> calendar, in which a year of days was divided into twelve months. The second month of the year lasted twenty-eight days, the first, third, fifth, seventh, eighth, tenth, and twelfth lasted thirty-one days, and the rest lasted thirty days. In special years, whose number was divisible by four and not divisible by one hundred, or was divisible by four hundred, the second month lasted twenty-nine days. A century with number was the period from year to year .
Since it is not known for certain in what order the members of the ancient civilization wrote dates, you, as the chief specialist in the Gregorian calendar, were tasked with a study: to determine which dates in the 21st century the inscription could correspond to, assuming that one of the numbers corresponds to the day of the month (days in each month were numbered from one), another of the numbers to the month number (months were also numbered from one), and the remaining number to the last two digits of the year in the 21st century of the Gregorian calendar.
Given the inscription on the disk, find out which dates in the 21st century it could correspond to.
Input
The input file contains the numbers from the disk in the format .
Output
In any order, output to the output file all valid dates in the 21st century, where is the day number, is the month number, and is the year number, and the numbers corresponding to , , and are permutations of the numbers on the disk.
If no permutation of the original numbers is a valid date in the 21st century, output <<No such date>>.