Dance

Problem Description
For a dance to be proper in the Altered Culture of Machinema, it must abide by the following rules:

1. A dip can only appear 1 or 2 steps after a jiggle, or before a twirl, as in:
* ...jiggle dip...
* ...jiggle stomp dip...
* ...dip twirl...
2. All dances end with a clap stomp clap.
3. If a dance contains a twirl, it must have a hop.
4. No dance can start with a jiggle.
5. All dances must have a dip.

As instructor at a dance composition school, you must grade many freshman attempts at composing dances. You decide to make an automatic grader that can check against these rules.

 
Input
The input consists of a number of dances, one per line. Each dance has a maximum of 1000 steps. Each step is separated by a single space, and all steps are lowercase alphabetic words at most 100 letters long.
 
Output
If a dance in the input has no mistakes, then the output should contain the words "form ok: " followed by the original composition.

If a dance has a single type of form error, then the output should contain the words "form error K: " where K is the rule which failed, followed by the composition.

If a dance has multiple types of form errors, then the output should contain the errors as a comma separated clause, as in "form errors K(1), K(2), ..., K(N-1) and K(N): " where the form errors are in increasing order, followed by the composition.

If a dance has form error 1, every dip in the dance that violates rule 1 should be printed in upper case.

 
Sample Input
dip twirl hop jiggle hop hop clap stomp clap
dip hop jiggle hop hop clap stomp clap
dip twirl hop jiggle hop hop clap clap stomp
jiggle dip twirl hop jiggle hop hop clap stomp clap
jiggle dip
jiggle
dip twirl hop dip jiggle hop dip hop clap stomp clap
 
Sample Output
form ok: dip twirl hop jiggle hop hop clap stomp clap
form error 1: DIP hop jiggle hop hop clap stomp clap
form error 2: dip twirl hop jiggle hop hop clap clap stomp
form error 4: jiggle dip twirl hop jiggle hop hop clap stomp clap
form errors 2 and 4: jiggle dip
form errors 2, 4 and 5: jiggle
form error 1: dip twirl hop DIP jiggle hop dip hop clap stomp clap
 
题意:
 给出一串 dance串
  问你是否满足 5个要求,不满足 输出哪些,对于要求1不满足 的dip都改成大写
  需要满足条件如下:
    1. A dip can only appear 1 or 2 steps after a jiggle, or before a twirl, as in:
* ...jiggle dip...
* ...jiggle stomp dip...
* ...dip twirl...
2. All dances end with a clap stomp clap.
3. If a dance contains a twirl, it must have a hop.
4. No dance can start with a jiggle.
5. All dances must have a dip.
  
题解:
  死模拟题
 
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include<vector>
using namespace std ;
typedef long long ll; const int N = + ;
const int inf = 1e9 + ; char a[N];
int len,H[N];
int check4() {
if(len < ) return ;
char b[] = {'j','i','g','g','l','e'};
int cnt = ;
for(int i = ; i < ; i++) {
if(a[i] != b[cnt]) return ;
cnt++;
}
return ;
}
int check2() {
if(len < ) return ;
char b[] = {"clap stomp clap"};
int cnt = ;
for(int i = len - ; i < len ;i ++) {
if(a[i]!=b[cnt++]) return ;
}
return ;
}
int check5() {
for(int i = ; i < len - ; i+=) {
if(a[i] == 'd' && a[i+] == 'i' && a[i+] == 'p') return ;
} return ;
}
int check3() {
if(len < ) return ;
for(int i = ; i <= len - ; i++) {
if(a[i] == 't' && a[i+] == 'w' && a[i+] == 'i' && a[i + ] == 'r'&&a[i+]=='l') {
for(int i = ; i < len - ; i++) {
if(a[i] == 'h' && a[i+] == 'o' && a[i+] == 'p') return ;
}
return ;
}
}
return ;
}
void solve() {
memset(H,,sizeof(H));
vector<int> ans;
len = strlen(a);
if(!check2()) H[] = ;
if(!check3()) H[] = ;
if(!check4()) H[] = ;
if( check5() ) {
for(int i = ; i < len - ; i++) {
if(a[i] == 'd' && a[i+] == 'i' && a[i+] == 'p') {
int f = ;
if(i - >= ) {
int cnt2= ;
for(int j = i - ; j >= ; j--) {
if(a[j] ==' ') cnt2++;
if(cnt2 == ) {cnt2 = j;break;}
}
if(cnt2 - >= ) {
int flag = ;
char b[] = {"jiggle"};int cnt = ;
for(int j = cnt2 - ; j < cnt2; j ++) {
if(a[j]!= b[cnt++]) {flag =;break;}
}
if(!flag) f = ;
}
}
if(i - >= ) {
int flag = ;
char b[] = {"jiggle "};int cnt = ;
for(int j = i - ; j < i; j ++) {
if(a[j]!= b[cnt++]) {flag =;break;}
}
if(!flag) f = ;
}
if(i + < len) {
int flag = ;
char b[] = {" twirl"};int cnt = ;
for(int j = i + ; j <= i+; j ++) {
if(a[j]!= b[cnt++]) {flag =;break;}
}
if(!flag) f = ;
}
if(f) {
a[i] = 'D';
a[i+] = 'I';
a[i+] = 'P';
H[] = ;
}
i += ;
}
}
}
else H[] = ;
for(int i = ; i <= ; i++) {
if(H[i]) ans.push_back(i);
}
if(!ans.size())cout<<"form ok: "<<a<<endl;
else if(ans.size()==) printf("form error %d: %s\n",ans[],a);
else if(ans.size() == ) printf("form errors %d and %d: %s\n",ans[],ans[],a);
else if(ans.size() == ) printf("form errors %d, %d and %d: %s\n",ans[],ans[],ans[],a);
else if(ans.size() == ) printf("form errors %d, %d, %d and %d: %s\n",ans[],ans[],ans[],ans[],a);
else if(ans.size() == ) printf("form errors %d, %d, %d, %d and %d: %s\n",ans[],ans[],ans[],ans[],ans[],a);
}
int main() {
while(gets(a)!=NULL) {
solve();
}
return ;
}
 
 

UVALive 4222 /HDU 2961 Dance 大模拟的更多相关文章

  1. HDU 5920 Ugly Problem 高精度减法大模拟 ---2016CCPC长春区域现场赛

    题目链接 题意:给定一个很大的数,把他们分为数个回文数的和,分的个数不超过50个,输出个数并输出每个数,special judge. 题解:现场赛的时候很快想出来了思路,把这个数从中间分为两部分,当位 ...

  2. AC日记——神奇的幻方 洛谷 P2615(大模拟)

    题目描述 幻方是一种很神奇的N*N矩阵:它由数字1,2,3,……,N*N构成,且每行.每列及两条对角线上的数字之和都相同. 当N为奇数时,我们可以通过以下方法构建一个幻方: 首先将1写在第一行的中间. ...

  3. ACdream 1188 Read Phone Number (字符串大模拟)

    Read Phone Number Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Sub ...

  4. 2016ACM-ICPC网络赛北京赛区 1001 (trie树牌大模拟)

    [题目传送门] 1383 : The Book List 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 The history of Peking University ...

  5. Bzoj1972: [Sdoi2010]猪国杀 题解(大模拟+耐心+细心)

    猪国杀 - 可读版本 https://mubu.com/doc/2707815814591da4 题目可真长,读题都要一个小时. 这道题很多人都说不可做,耗时间,代码量大,于是,本着不做死就不会死的精 ...

  6. (大模拟紫题) Luogu P1953 易语言

    原题链接:P1953 易语言 (我最近怎么总在做大模拟大搜索题) 分别处理两种情况. 如果只有一个1或0 直接设一个cnt为这个值,每次输入一个新名字之后把数字替换成cnt,最后cnt++即可. 注意 ...

  7. NOIP2017 时间复杂度 大模拟

    再写一道大模拟题. 由于是限时写的,相当于考场代码,乱的一批. 题目链接:P3952 时间复杂度 先记几个教训: 字符串形式的数字比较大小老老实实写函数,字典序都搞错几次了 栈空的时候不但pop()会 ...

  8. [CSP-S模拟测试]:引子(大模拟)

    题目描述 网上冲浪时,$Slavko$被冲到了水箱里,水箱由上而下竖直平面.示意图如下: 数字$i$所在的矩形代表一个编号为$i$的水箱.1号水箱为水箱中枢,有水管连出.除了$1$号水箱外,其他水箱上 ...

  9. 模拟赛38 B. T形覆盖 大模拟

    题目描述 如果玩过俄罗斯方块,应该见过如下图形: 我们称它为一个 \(T\) 形四格拼板 .其中心被标记为\(×\). 小苗画了一个 \(m\) 行 \(n\) 列的长方形网格.行从 \(0\) 至 ...

随机推荐

  1. Atom介绍和安装步骤

    Atom是全然基于web技术开发而成的一款编辑器,其底层架构依赖于chromium,google chrome浏览器也是基于此.编辑器的每一个窗体都是本地渲染的web页面,而且其风格与时下流行的sub ...

  2. 0x29 总结与练习

    搜索真的菜..困扰了很久,上个星期天没休息好导致整个礼拜没有精神.. 大概完成得七七八八了吧.真是深切的体会到暴力出奇迹的疯狂啊. 3.虫食算 从末位开始枚举判断,通过加数可以推出和的字母代表的数.那 ...

  3. java 中的静态(static)代码块

    类字面常量 final 静态域不会触发类的初始化操作 非 final static 静态域(以及构造器其实是一种隐式的静态方法) Class.forName():会自动的初始化: 使用 .class来 ...

  4. Oracle 性能优化的基本方法

    Oracle 性能优化的基本方法概述 1)设立合理的性能优化目标. 2)测量并记录当前性能. 3)确定当前Oracle性能瓶颈(Oracle等待什么.哪些SQL语句是该等待事件的成分). 4)把等待事 ...

  5. idea设置Template

    在eclipse里面经常会用到syso和main类似这样的内容,但是idea工具里面没有,可以通过 Editor ==> Live templates  ==> 1.首先创建一个自己的Te ...

  6. ROS-多机通信

    前言:一定要在同一路由的局域网下进行,就是两台电脑的ip要像这样:192.168.191.4和192.168.191.8,只有最后一位不同,这样就能ping通了,否则ping不同. 一.查看ip和主机 ...

  7. uploadifive上传文件

    uploadifive是一个款基于H5的上传文件的插件.优点是,可以在PC端,也可以在手机上进行操作.缺点是,IE9以下的兼容性不好. View: <!DOCTYPE html> < ...

  8. VSCode Debug模式下各图标 含义

    按钮1:运行/继续 F5,真正的一步一步运行 按钮2:单步跳过(又叫逐过程) F10,按语句单步执行.当有函数时,不会进入函数. 按钮3:单步调试(又叫逐语句) F11:当有函数时,点击这个按钮,会进 ...

  9. ZBrush中如何清除画布中多余图像

    ZBrush是一款数字雕刻与绘画软件,它以强大的功能和直观的工作流程彻底改变了整个三维行业.它的简洁化.智能化和人性化的设计无不让众多用户所折服.刚接触它的用户可能会因为找不到相关命令或不熟悉而觉得它 ...

  10. luogu P3387 【模板】缩点_拓扑排序

    还是很好些的. Code: #include <stack> #include <cstdio> #include <algorithm> #include < ...