Poetry
InterviewTime limit1sMemory limit128 MB
For each four-line verse, extract the last syllable of the final word on every line and print which rhyme scheme it matches.
- Level
Easy3 of 10
- Topics
- String, Implementation, Hash map, Simulation
- Solved
- No attempts yet
Problem
A simple poem consists of one or more four-line verses. Each line contains one or more words made of uppercase and/or lowercase letters, and adjacent words on a line are separated by a single space.
The last syllable of a word is the sequence of letters from its last vowel (a, e, i, o, or u; y is not a vowel) to the end of the word. If a word contains no vowel, its last syllable is the whole word. Two lines rhyme when the last syllables of their final words are equal, ignoring letter case.
For each verse, classify its rhyme form as one of perfect, even, cross, shell, or free:
- perfect: all four lines rhyme with one another.
- even: the first two lines rhyme, and the last two lines rhyme.
- cross: the first and third lines rhyme, and the second and fourth lines rhyme.
- shell: the first and fourth lines rhyme, and the second and third lines rhyme.
- free: any verse that is not perfect, even, cross, or shell.
Check the forms in the order above: a verse is perfect if all four lines rhyme; otherwise it may be even, cross, or shell; if none of these apply, it is free.
Input
The first line contains an integer — the number of verses in the poem ().
The next lines contain the poem, four lines per verse in order. Each of these lines has at most characters, consisting only of letters and single spaces between words.
Output
Print lines. On the -th line, print the rhyme form of the -th verse: one of perfect, even, cross, shell, or free.