Editorial for COCI '12 Contest 5 #1 Ljestvica


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.

The basic idea: We use a variable Amin to count accented tones that are main tones in A-minor, and a variable Cmaj to count accented tones that are main tones in C-major.

Implementation details: One traversal (using a for-loop) over the input string is used to find accented tones in the following way: a tone is accented if it is the first character in the string, or if the previous character was |. For each accented tone, we can use a branching statement (such as if-then-else or switch-case) to check whether it is equal to C, F, or G (in which case we increment the variable Cmaj), or to A, D, or E (in which case we increment the variable Amin).

Finally, it is obvious what we need to output if Amin < Cmaj or if Amin > Cmaj. If, on the other hand, Amin = Cmaj, we simply need to check whether the last character of the input string is A or C, as defined in the problem statement.


Comments

There are no comments at the moment.