Editorial for COCI '12 Contest 5 #1 Ljestvica
Submitting an official solution before solving the problem yourself is a bannable offence.
The basic idea: We use a variable to count accented tones that are main tones in A-minor, and a variable 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 ), or to A
, D
, or E
(in which case we increment the variable ).
Finally, it is obvious what we need to output if or if . If, on the other hand, , we simply need to check whether the last character of the input string is A
or C
, as defined in the problem statement.
Comments