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. UVA 11825 Hackers’ Crackdown 状压DP枚举子集势

    Hackers’ Crackdown Miracle Corporations has a number of system services running in a distributed com ...

  2. 【转】iOS 设置APP的名称(浅述APP版本国际化与本地化)

    原文网址:http://www.jianshu.com/p/a3a70f0398c4 前言 App的名字设置方式有很多种,如果在App打包上线时不做修改,最终App的名字就是Xcode在建立工程时的名 ...

  3. js写发布微博文本框---2017-04-14

    实现效果: 1.文本框输入内容,低端字数对应减少 2.当文本框内容超出时,会显示字数超出多少 效果图如下: 实现代码: <!DOCTYPE html><html> <he ...

  4. Spark SQL 编程API入门系列之Spark SQL支持的API

    不多说,直接上干货! Spark SQL支持的API SQL DataFrame(推荐方式,也能执行SQL) Dataset(还在发展) SQL SQL 支持basic SQL syntax/Hive ...

  5. vue中slot组件的使用

    插槽(Slot)是Vue提出来的一个概念,正如名字一样,插槽用于决定将所携带的内容,插入到指定的某个位置,从而使模板分块,具有模块化的特质和更大的重用性. Slot 是在组件模板中设置的用于在父组件中 ...

  6. Java操作Kafka执行不成功

    使用kafka-clients操作kafka始终不成功,原因不清楚,下面贴出相关代码及配置,请懂得指点一下,谢谢! 环境及依赖 <dependency> <groupId>or ...

  7. Temporary Tables临时表

    1简介 ORACLE数据库除了可以保存永久表外,还可以建立临时表temporary tables.这些临时表用来保存一个会话SESSION的数据, 或者保存在一个事务中需要的数据.当会话退出或者用户提 ...

  8. pixhawk入门知识

    Pixhawk是一种先进的自动驾驶仪,由PX4开放硬件项目设计和3D机器人制造.它具有来自ST公司先进的处理器和传感器技术,以及NuttX实时操作系统,能够实现惊人的性能,灵活性和可靠性控制任何自主飞 ...

  9. java 公开内部类无法实例化 no enclosing instance 解决办法

    因为B类不是A类的静态内部类,所以B累也只能像A类的成员一样通过new A()的实例访问,new(new A()).B(),这显然不是我们想要的方式,于是需要在B类的前边加上static,变成下边这样 ...

  10. 【Jim】I am back (ง •_•)ง

    其实上周就来考过一次试了,真是啥都忘了 (´ー∀ー`) 下午在写[树网的核],写了一半去吃饭,回来时发现高二机房的门被锁上了,于是他们都被堵在门口. 我就回到我的地方接着写码. 听到外面有个高二的妹子 ...