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 单点修改 如果没有第二个操作的话,就是一棵简单的线段树.那么如 ...
随机推荐
- C语言隐式强制类型转换
今天又被精度问题困扰,把最基本的东西忘了. int n = 5; int cnt = 5.5; double sum = (n-cnt); 运算完后sum是 -0.5.不知道什么时候n转换成doub ...
- lldp中与snmp相关内容agentx
struct lldpd { int g_snmp; struct event *g_snmp_timeout; void *g_snmp_fds; char *g_snmp_agen ...
- LeetCode OJ 101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For e ...
- java和.net的类比
原文地址在http://www.seguetech.com/blog/2013/06/03/dotnet-vs-java-how-to-pick
- Postgres数据库在Linux中的I/O优化
I/O 优化1 打开 noatime方法: 修改 /etc/fstab2 调整预读方法: 查看 sudo blockdev --getra /dev/sda 设置 sudo blockdev --se ...
- Apache 与tomcat区别
Apache与Tomcat有什么关系和区别 经常在用apache和tomcat等这些服务器,可是总感觉还是不清楚他们之间有什么关系,在用tomcat的时候总出现apache,总感到迷惑,到底谁是主谁是 ...
- C#输出日历
用C#输出日历,此功能可用于Ajax方式列出计划日程相关的内容,由于是C#控制输出,可以方便加上自己需要的业务处理逻辑. 1.控制台输出: using System; namespace 控制台日历 ...
- Server的Transfer和Response的Redirect
在实现页面跳转的时候,有些人喜欢用Response.Redirect,而有些人则喜欢用Server.Transfer.大部分时间似乎这两种方法都可以实现相同的功能,那究竟有区别吗? 查了些文档,发现两 ...
- 解决centos无法上传文件和打开文件夹
使用yum搭建了ftp服务..yum的使用参考:http://blog.csdn.net/enson16855/article/details/9140623 windows使用FileZilla连接 ...
- OpenGL ES之glUniform函数
函数名: glUniform 功能: 为当前程序对象指定Uniform变量的值.(译者注:注意,由于OpenGL ES由C语言编写,但是C语言不支持函数的重载,所以会有很多名字相同后缀不同的函数版本存 ...