C. Literature Lesson time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard outputadmin管理员组文章数量:1630554
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 kvowels, 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.
<p< p="" style="font-family: verdana, arial, sans-serif; font-size: 14px; line-height: 21px; "><p< p=""> Input <p< p="">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 4n 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.
<p< p=""><p< p=""> Output <p< p="">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.
<p< p=""><p< p=""> Sample test(s) <p< p=""><p< p=""> input1 1 day may sun funoutput
aabbinput
1 1 day may gray wayoutput
aaaainput
2 1 a a a a a a e eoutput
aabbinput
2 1 day may sun fun test hill fest thrilloutput
NO<p< p=""><p< p=""> Note <p< p="">
In the last sample both quatrains have rhymes but finding the common scheme is impossible, so the answer is "NO".
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char lett[5][5]={{"aaaa"},{"aabb"},{"abab"},{"abba"},{"NO"}};
bool outt[5];
char ler[5][8];
int lern[5][8];
char lets[4][10000+10];
int main()
{
char str[10000+10];
int n,k,len;
int i,j,p,t,q;
while(scanf("%d%d",&n,&k)!=EOF)
{
getchar();
memset(outt,true,sizeof(outt));
for(i = 0;i<n;i++)
{
for(j = 0;j<4;j++)
{
scanf("%s",&str);
len = strlen(str);
t = k;
q = 0;
for(p = len-1;p>=0&&t>0;p--)
{
lets[j][q++] = str[p];
if(str[p]=='a'||str[p]=='e'||str[p]=='i'||str[p]=='o'||str[p]=='u')
{
t--;
}
}
lets[j][q]='\0';
if(t>0)
{
outt[0] = false;
outt[1] = false;
outt[2] = false;
outt[3] = false;
}
}
if(strcmp(lets[0],lets[1])!=0||strcmp(lets[1],lets[2])!=0||strcmp(lets[2],lets[3])!=0)
outt[0] = false;
if(strcmp(lets[0],lets[1])!=0||strcmp(lets[2],lets[3])!=0)
outt[1] = false;
if(strcmp(lets[0],lets[2])!=0||strcmp(lets[1],lets[3])!=0)
outt[2] = false;
if(strcmp(lets[0],lets[3])!=0||strcmp(lets[1],lets[2])!=0)
outt[3] = false;
}
for(i = 0;i<=5;i++)
{
if(outt[i])
{
printf("%s\n",lett[i]);
break;
}
}
}
return 0;
}
加油!!相信会好的,一切都会好起来的。
本文标签: CFlessonLiterature
版权声明:本文标题:cf#99 C. Literature Lesson 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1729056842a1184064.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论