CF138A.Literature Lesson
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their suffixes that start from the k-th vowels (counting from the end) match. If a line has less than k vowels, then such line can't rhyme with any other line. For example, if k = 1, lines commit and hermit rhyme (the corresponding suffixes equal it), and if k = 2, they do not rhyme (ommit ≠ ermit).
Today on a literature lesson Vera learned that quatrains can contain four different schemes of rhymes, namely the following ones (the same letters stand for rhyming lines):
- Clerihew (aabb);
- Alternating (abab);
- Enclosed (abba).
If all lines of a quatrain pairwise rhyme, then the quatrain can belong to any rhyme scheme (this situation is represented by aaaa).
If all quatrains of a poem belong to the same rhyme scheme, then we can assume that the whole poem belongs to this rhyme scheme. If in each quatrain all lines pairwise rhyme, then the rhyme scheme of the poem is aaaa. Let us note that it doesn't matter whether lines from different quatrains rhyme with each other or not. In other words, it is possible that different quatrains aren't connected by a rhyme.
Vera got a long poem as a home task. The girl has to analyse it and find the poem rhyme scheme. Help Vera cope with the task.
薇拉非常喜爱诗歌。她所知道的所有诗歌都被划分为四行诗(即由四行组成的诗节),且每个四行诗中都有若干行押韵。
我们假设诗歌中的所有行均由小写拉丁字母(不含空格)组成。字母 “a”、“e”、“i”、“o”、“u” 被视为元音字母。
当两行从末尾起第 k 个元音(从末尾开始计数)起的后缀相同时,这两行即为押韵。若某行所含元音总数少于 k 个,则该行无法与任何其他行押韵。例如,当 k=1 时,“commit” 与 “hermit” 押韵(对应后缀均为 “it”);而当 k=2 时,它们不押韵(“ommit” = “ermit”)。
今天在文学课上,薇拉了解到四行诗可能包含四种不同的押韵格式,具体如下(相同字母代表相互押韵的行):
- 克莱里休(Clerihew):
aabb; - 交替式(Alternating):
abab; - 包围式(Enclosed):
abba。
若一个四行诗中所有行两两押韵,则该四行诗可归属任意一种押韵格式(这种情况用 aaaa 表示)。
若一首诗中所有四行诗均属于同一种押韵格式,则称整首诗属于该押韵格式。若每四行诗中所有行均两两押韵,则该诗的押韵格式为 aaaa。注意:不同四行诗之间的各行是否押韵无关紧要。换言之,不同四行诗之间可以完全不构成押韵关系。
薇拉收到了一首很长的诗歌作为家庭作业。她需要分析这首诗并确定其押韵格式。请帮助薇拉完成这项任务。
输入格式
The first line contains two integers n and k (1 ≤ n ≤ 2500, 1 ≤ k ≤ 5) — the number of quatrains in the poem and the vowel's number, correspondingly. Next 4_n_ lines contain the poem. Each line is not empty and only consists of small Latin letters. The total length of the lines does not exceed 104.
If we assume that the lines are numbered starting from 1, then the first quatrain contains lines number 1, 2, 3, 4; the second one contains lines number 5, 6, 7, 8; and so on.
第一行包含两个整数 n 和 k(1≤n≤2500,1≤k≤5),分别表示诗中四行诗(quatrain)的数量以及元音字母的编号。接下来的 4n 行包含这首诗。每行非空,且仅由小写拉丁字母组成。所有行的总长度不超过 104。
若将各行从 1 开始编号,则第一个四行诗包含第 1,2,3,4 行;第二个四行诗包含第 5,6,7,8 行;依此类推。
输出格式
Print the rhyme scheme of the poem as "aabb", "abab", "abba", "aaaa"; or "NO" if the poem does not belong to any of the above mentioned schemes.
输出诗歌的韵式,格式为“aabb”、“abab”、“abba”或“aaaa”;如果该诗歌不属于上述任一韵式,则输出“NO”。
输入输出样例
输入#1
1 1 day may sun fun
输出#1
aabb
输入#2
1 1 day may gray way
输出#2
aaaa
输入#3
2 1 a a a a a a e e
输出#3
aabb
输入#4
2 1 day may sun fun test hill fest thrill
输出#4
NO
说明/提示
In the last sample both quatrains have rhymes but finding the common scheme is impossible, so the answer is "NO".
在最后一个样例中,两个四行诗都有押韵,但无法找到共同的韵式,因此答案为“NO”。
输入解题思路,AI测评打分。不知道怎么写?