Editorial for COCI '14 Contest 2 #1 Mobitel


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.

Let us imagine for a moment that the grasshopper's mobile phone didn't fall into a puddle. In that case, the task comes down to a simulation of writing a word using the phone's keys. In order to achieve the aforementioned simulation, for each letter in the word, we add to the solution the number of pressed keys needed to get to that letter (according to the image from the task). Additionally, we have to be careful to separate pressing consecutive letters from the same key with #.

When we find a solution obtained by the above method, it is sufficient to replace every occurrence of key x with key y if key y acts like key x. This simple modification solves the grasshopper's problem.


Comments

There are no comments at the moment.