Editorial for COCI '19 Contest 6 #1 Datum


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
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 1 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, 366 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 \mathcal O(NK), where K represents the number of palindromic dates. The task can also be solved in \mathcal O(N \log K), but we will leave that solution as an exercise to the reader.


Comments

There are no comments at the moment.