这个题,读懂了就是水,读不懂就没办法下手,论英语阅读的重要性...只有五种形式,第一种万能型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. 用php和imagemagick来处理图片文件的上传和缩放处理

    啥也不说,直接上代码,大家可以自行添加增加水印功能: <?php /** * * @author zhao jinhan * @date 2014年1月13日11:54:30 * @email  ...

  2. 深入浅出requireJS-1

    我们都知道,虽然我们可以通过原型和继承来使javascript面向对象.但是,当js代码和逻辑过多时,代码的维护和扩展会变的很不方便.这时,nodejs做的非常好,但是在浏览器端模块化的js编程一直都 ...

  3. spark 编程向导

    http://spark.apache.org/docs/latest/programming-guide.html

  4. JavaScript高级程序设计:第七章

    函数表达式 1.函数表达式的特征: 定义函数的方式有两种:一种是函数声明,另一种就是函数表达式.函数声明的语法是这样的: function  functionName(arg0,arg1,arg2){ ...

  5. java中的静态初始化块

    Java 中可以通过初始化块进行数据赋值.如: 在类的声明中,可以包含多个初始化块,当创建类的实例时,就会依次执行这些代码块.如果使用 static 修饰初始化块,就称为静态初始化块. 需要特别注意: ...

  6. Spring Security-用户密码自定义加密

    public class SunPasswordEncoder implements PasswordEncoder{ //@实现加密的方法,既将明文转换为密文的方法 public String en ...

  7. js跨域访问,No ‘Access-Control-Allow-Origin‘ header is present on

    在本地用ajax跨域访问请求时报错: XMLHttpRequest cannot loadhttp://www.zjblogs.com/. No 'Access-Control-Allow-Origi ...

  8. bind启动时提示953端口被使用

    部署DNS的时候遇到个奇葩的问题,总是提示 couldn't add command channel 0.0.0.0#953: address in use 实际上系统上并没有进程使用953端口.查询 ...

  9. perl中my和our的区别分析

    来源: http://www.jb51.net/article/35528.htm perl中our的用法require 5.006当版本号小于 5.006 的时候,会返回失败,从而导致模块加载失败. ...

  10. HttpWebRequest 抓取页面异常处理办法

    抓取页面异常处理办法 public static string GetHtmlTest(string URI) { string fullhtml = null; while (true) { try ...