这个题,读懂了就是水,读不懂就没办法下手,论英语阅读的重要性...只有五种形式,第一种万能型aaaa,是另外3种的特殊情况,第二种克莱里林四行打油诗aabb形式,第三种是交替的abab形式,第四种是封闭的abba形式,第五种就是NO.题目的意思就是给我们四个原串,让我们counting from the end(从后往前数)找到第k个元音字母,从这个位置截取原串的suffixes(后缀),形成四个新串,判断这四个新串符合以上五中情况中的哪一个.如果原串不足k个元音字母,那情况直接就是no.在判断的时候需要注意aaaa不用管,它可以与任意情况重合(除NO以外),而剩下的4中任意两种都不可重合,代码及注释如下:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
bool mark[];///0=aaaa,1=aabb,2=abab,3=abba,4=NO
char str[],newstr[][];
char output[][] = {"aabb","abab","abba"};
void Judge()
{
if( !strcmp(newstr[],newstr[])&& !strcmp(newstr[],newstr[])&& !strcmp(newstr[],newstr[]))
mark[] = ;
else if(!strcmp(newstr[],newstr[])&&!strcmp(newstr[],newstr[])) mark[] = ;
else if(!strcmp(newstr[],newstr[])&&!strcmp(newstr[],newstr[])) mark[] = ;
else if(!strcmp(newstr[],newstr[])&&!strcmp(newstr[],newstr[])) mark[] = ;
else mark[] = ;
}
bool Is_vowels(char a)
{
if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u') return true;
return false;
}
int main()
{
int n,k;
scanf("%d%d",&n,&k);
memset(mark,,sizeof(mark));
while(n--)
{
//memset(newstr,0,sizeof(newstr));
int tot,ok=;
for(int i = ; i < ; i++)
{
scanf("%s",str);
int lens = strlen(str),pos;
tot=;
for(int j = lens-; j >= ; j--)
{
if(Is_vowels(str[j]))
{
tot++;
}
if(tot == k)
{
pos = j;
break;
}
}
if(tot < k)
{
mark[] = ;
ok = ;
}
if(tot == k)///这个判断必须要有,否则RE
{
for(int j = pos; j < lens; j++)
{
newstr[i][j-pos] = str[j];
}
newstr[i][lens-pos] = '\0';///换行符结束标识
}
}
if(ok)
Judge();
}
if(mark[]) puts("NO");///注意判断顺序
else
{
bool flag = true;
for(int i = ; i <= ; i++)
{
for(int j = i+; j <= ; j++)
{
if(mark[i] && mark[j])
{
flag = false;
break;
}
}
}
if(!flag) puts("NO");
else if(flag)
{
for(int i = ; i <= ; i++)
{
if(mark[i])
{
printf("%s\n",output[i-]);
flag = false;
break;
}
}
if(flag)
{
puts("aaaa");
}
}
}
return ;
}

CodeForces 139C Literature Lesson(模拟)的更多相关文章

  1. Codeforces 738D. Sea Battle 模拟

    D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard inp ...

  2. Codeforces 626A Robot Sequence(模拟)

    A. Robot Sequence time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...

  3. CodeForces - 589D(暴力+模拟)

    题目链接:http://codeforces.com/problemset/problem/589/D 题目大意:给出n个人行走的开始时刻,开始时间和结束时间,求每个人分别能跟多少人相遇打招呼(每两人 ...

  4. Codeforces 767B. The Queue 模拟题

    B. The Queue time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...

  5. Codeforces 704A Thor 队列模拟

    题目大意:托尔有一部手机可执行三种操作 1.x APP产生一个新消息 2.读取x App已产生的所有消息 3.读取前t个产生的消息 问每次操作后未读取的消息的数量 题目思路: 队列模拟,坑点在于竟然卡 ...

  6. Vasya And The Mushrooms CodeForces - 1016C (前缀和模拟)

    大意: 给定2*n的矩阵, 每个格子有权值, 走到一个格子的贡献为之前走的步数*权值, 每个格子只能走一次, 求走完所有格子最大贡献. 沙茶模拟打了一个小时总算打出来了 #include <io ...

  7. Codeforces 691C. Exponential notation 模拟题

    C. Exponential notation time limit per test: 2 seconds memory limit per test:256 megabytes input: st ...

  8. Codeforces 658A. Robbers' watch 模拟

    A. Robbers' watch time limit per test: 2 seconds memory limit per test: 256 megabytes input: standar ...

  9. Codeforces 438D (今日gg模拟第二题) | 线段树 考察时间复杂度的计算 -_-|||

    Codeforces 438D The Child and Sequence 给出一个序列,进行如下三种操作: 区间求和 区间每个数模x 单点修改 如果没有第二个操作的话,就是一棵简单的线段树.那么如 ...

随机推荐

  1. classpath获取--getResource()

    在java中的API里,有两种方式来使用classpath读取资源. 1. Class的getResource() 2. ClassLoader的getResource() 但是两者有一定区别,运行以 ...

  2. simHash 简介以及java实现

    http://gemantic.iteye.com/blog/1701101 simHash 简介以及java实现 博客分类: 算法 simHash java 去重  传统的hash 算法只负责将原始 ...

  3. hdu_4714_Tree2cycle(树形DP)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4714 题意:给你N个点N-1条边,形成一个树,让你拆树,并连接成一个环,每拆一次,连接一次,消耗1,问 ...

  4. linuxmint计算器

    命令行输入bc进入计算器, 可以计算 + 加法 - 减法* 乘法 / 除法^ 指数 % 余数 quit   关闭计算器

  5. 关于PHP执行超时的问题

    PHP配置文件的参数max_execution_time表示脚本执行超时时间 max_execution_time=0表示不限制 max_execution_time=2表示执行两秒后终止,同时报错F ...

  6. 今天修改 wifi hal 的时候碰见一个问题

    今天修改 supplicant_name的时候出现一个问题. 发现原来init.wifi.rc 的server的时候出现了一个问题. 名字不对,没有和 supplicant_name对应起来. 所以就 ...

  7. wget mirror

    wget -r -np -c xxx-url-xxx -r: recursive-np: no-parent-c: continue -D: domains to follow, comma sepa ...

  8. C#判断文字是否为汉字

    /// <summary> /// 检测一个字符串是不是以汉字开始 /// </summary> /// <param name="str">要 ...

  9. n++与++n的区别

    n++ 是先执行n++再进行赋值返回的只却是n. ++n 是先赋值之后再执行++n. 其实执行 n++ and ++n 都算是一次赋值 所以若 n = n++ and n = ++n 其实就是2次赋值 ...

  10. java.sql.ResultSet技术(从数据库查询出的结果集里取列值)

    里面有一个方法可以在查询的结果集里取出列值,同理,存储过程执行之后返回的结果集也是可以取到的. 如图: 然后再运用 java.util.Hashtable 技术.把取到的值放入(K,V)的V键值里,K ...