COCI '25 Contest 1 #1 Rima
View as PDF
In Croatian class, Jakov reads a poem consisting of lines and
stanzas. Lines
,
,
, and
make up the first stanza, lines
,
,
, and
the second stanza, and so on. Each line in each stanza consists of exactly
words.
We say that two lines rhyme if the last letters of their last words match. If the last word in one of the lines consists of fewer than
letters, then the lines do not rhyme.
At the stanza level, we distinguish three types of rhyme schemes:
– lines
and
rhyme, and lines
and
rhyme
– lines
and
rhyme, and lines
and
rhyme
– lines
and
rhyme, and lines
and
rhyme
The teacher asked Jakov to determine in how many stanzas of the poem each of these three types of rhyme schemes appears. Help Jakov answer the teacher correctly and get an A in Croatian class!
Input Specification
The first line contains the natural numbers ,
and
and
is divisible by
,
from the text of the task.
The next lines contain
words each, with each word being made up of at most
lowercase letters of the English alphabet.
Output Specification
In the first and only line, write three numbers: the number of stanzas in which rhyme appears, the number of stanzas in which
rhyme appears, and the number of stanzas in which
rhyme appears.
Constraints
| Subtask | Points | Constraints |
|---|---|---|
| Each word is made up of |
||
| No additional constraints. |
Sample Input 1
8 2 3
aa bb
cc bb
dd ee
ff ee
auu aaaaaahh
auu wer
asdf power
lol kldahh
Sample Output 1
0 0 1
Explanation for Sample Output 1
In the first stanza, not a single pair of lines can rhyme, because each last word has only letters, and
. The second stanza follows an
rhyme scheme because the
st and
th lines rhyme (
aaaaaahh and kldahh), and the nd and
rd lines also rhyme (
wer and power). Thus, and
rhymes occur
times, while
rhyme occurs once.
Sample Input 2
8 2 2
ja programiram
mjesec listopad
ponekad chillam
voda vodopad
banana jabuka
fiziku znam
teska odluka
njam njam
Sample Output 2
0 2 0
Sample Input 3
4 4 2
pas konj zec macka
trokut teziste poluravnina tocka
nogomet tenis ragbi odbojka
sir mlijeko kulen sunka
Sample Output 3
1 1 1
Explanation for Sample Output 3
In the only stanza of this poem, the last two letters of the last word in each line are ka, so all lines rhyme with each other. It follows that all three types of rhyme schemes appear in this stanza: ,
and
.
Comments