CodeForces 139C Literature Lesson(模拟)
这个题,读懂了就是水,读不懂就没办法下手,论英语阅读的重要性...只有五种形式,第一种万能型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(模拟)的更多相关文章
- Codeforces 738D. Sea Battle 模拟
D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard inp ...
- Codeforces 626A Robot Sequence(模拟)
A. Robot Sequence time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...
- CodeForces - 589D(暴力+模拟)
题目链接:http://codeforces.com/problemset/problem/589/D 题目大意:给出n个人行走的开始时刻,开始时间和结束时间,求每个人分别能跟多少人相遇打招呼(每两人 ...
- Codeforces 767B. The Queue 模拟题
B. The Queue time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...
- Codeforces 704A Thor 队列模拟
题目大意:托尔有一部手机可执行三种操作 1.x APP产生一个新消息 2.读取x App已产生的所有消息 3.读取前t个产生的消息 问每次操作后未读取的消息的数量 题目思路: 队列模拟,坑点在于竟然卡 ...
- Vasya And The Mushrooms CodeForces - 1016C (前缀和模拟)
大意: 给定2*n的矩阵, 每个格子有权值, 走到一个格子的贡献为之前走的步数*权值, 每个格子只能走一次, 求走完所有格子最大贡献. 沙茶模拟打了一个小时总算打出来了 #include <io ...
- Codeforces 691C. Exponential notation 模拟题
C. Exponential notation time limit per test: 2 seconds memory limit per test:256 megabytes input: st ...
- Codeforces 658A. Robbers' watch 模拟
A. Robbers' watch time limit per test: 2 seconds memory limit per test: 256 megabytes input: standar ...
- Codeforces 438D (今日gg模拟第二题) | 线段树 考察时间复杂度的计算 -_-|||
Codeforces 438D The Child and Sequence 给出一个序列,进行如下三种操作: 区间求和 区间每个数模x 单点修改 如果没有第二个操作的话,就是一棵简单的线段树.那么如 ...
随机推荐
- JS进阶书籍
http://blog.csdn.net/bingqingsuimeng/article/details/40535291 本来想尝试每天回答或看已解决的3个问题来学习总结今天的知识点,看了下博文里面 ...
- Redis中connect和pconnect的区别
首先先介绍下connect和pconnect的区别.connect:脚本结束之后连接就释放了. pconnect:脚本结束之后连接不释放,连接保持在php-fpm进程中.所以使用pconnect代替c ...
- psy
本文的重点是讲解如何运用心理线指标看盘,运用周线月线的心理线来抓住大盘的顶部和底部的研究.分析研究的材料都来源于沪市历史上的顶部和底部的历史数据.从psy数据所得出的结论大多数是有效的,只有个别时期的 ...
- webwork <ww:if> 标签的使用
如果在前台(JSP)取出后台的对象的属性,这个属性在后台是属于String 类型的,但若这个属性的值为数字,取出在前台就会默认为整形的值,所以在<ww:if> 判断里面不能加引号:< ...
- wpf之Popup弹出自定义输入"键盘"
在很多工厂的信息化MES系统中,车间的采集数据的机器是触摸屏电脑(工厂环境所限,用外接鼠标键盘反而不方便). 由于没有外接键盘,所以用户无法像坐在办公室一样,用鼠标键盘进行录入信息. 这时我们可以用w ...
- 01_change_schema.sql
set echo on feedback on spool ./log/01_change_schema.log -- -- schema change to v_idocdata_un -- -- ...
- mysql具体语句示例
建表:(not null ,auto_increment, unique , primary key) create database balfish;use balfish;create table ...
- 【纯欧拉函数】 poj 2407
#include <cstdio> #include <iostream> using namespace std; int phi(int x) { int t=x; ;i& ...
- db2导入表结构和表数据
http://www.cnblogs.com/kfarvid/archive/2010/12/15/1906776.html db2的博文 -bash-3.2$ db2 connect to ca ...
- [转]修改hosts文件不起作用
http://wayne173.iteye.com/blog/1876565 今天遇到个很奇怪的问题,在hosts文件里添加了一些域名指向后,发现根本没起作用,后来还发现个细节,就是hosts文件左下 ...