Editorial for COCI '16 Contest 2 #2 Tavan

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 of points, the ink is spilled over only one letter, so it is sufficient to alphabetically sort the letters that could replace it and use the one. This is a good example of a task where a simple approach can get you a large number of points.

There are multiple solutions where it is possible to obtain all points. One of them is to convert the number to a number in a numerical system where the base is . For easier implementation, we pad the number with leading zeros so that the total number of digits is . Let the digits of the new number be , respectively. Then the unknown letter must be replaced by the letter from the sorted order of letters that could potentially replace the letter (the letters in the sorted order are 0-indexed).

The time complexity of this solution is .