Editorial for COCI '19 Contest 6 #1 Datum
Submitting an official solution before solving the problem yourself is a bannable offence.
For the first subtask, it was enough to take the first two characters of the date and increase that number by until we reach a palindrome.
For the second subtask, we can use the same approach as for the first one, but we need to take additional care when we enter a new month.
For the third subtask, we can use the same approach as for the first two, but we need to take additional care when we enter a new year.
In order to score all points, it was important to note that the number of palindromic dates in the given form is relatively small, in total. You could simply find these dates and store them in an array. For each date in the input, you can traverse through all palindromic dates and output the smallest one that comes after it.
The time complexity is , where represents the number of palindromic dates. The task can also be solved in , but we will leave that solution as an exercise to the reader.
Comments