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. JPA实现一对多(OneToMany)关联

    转自:https://blog.csdn.net/qq_32444825/article/details/77084580 1.考试类 @Entity public classExam impleme ...

  2. vue.js的学习之路

    因为对jquery的ajax渲染很不满,所以我就来学vue.js了 1)vue.js是什么 官方解释为:Vue (读音 /vjuː/,类似于 view) 是一套用于构建用户界面的渐进式框架.与其它大型 ...

  3. 完整注册+JQuery验证+selert后台校验

    Java代码 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8 ...

  4. POJ 3260 DP

    只需要对John的付款数做一次多重背包,对shopkeeper的找零钱数做一次完全背包即可. 最重要的是上界的处理.可以注意到,John的付款数最多为maxv*maxv+m,也就是24400元.同理, ...

  5. 读书笔记之《HTML5 与 CSS3 基础教程》

    1· 读前预期 考虑到对于 Web 开发零基础,凡涉足一件未知的任务,最好先理清任务的逻辑结构,然后有目的地逐步学习.为实现我们的需求和设计,必须要学习前端.后端.服务器等一系列暂时陌生的知识,在此, ...

  6. Python写99乘法表

    #!/usr/bin/python# -*- encoding:utf-8 -*- for i in range(1,10):    s=''    for j in range(1,i+1):    ...

  7. Win10 build package error collections

    1. 打包Released的时候出现问题意思是说 本地项目,类里有这个Visibility属性不能进行序列化 严重性 代码 说明 项目 文件 行 禁止显示状态 错误 error CS0029: 无法将 ...

  8. php语法学习:轻松看懂PHP语言

    基础语法 开头结尾 PHP脚本以 "<?php " 开头以 "?>" 结尾 <!DOCTYPE html> <html>&l ...

  9. Tensorflow学习笔记----模型的保存和读取(4)

    一.模型的保存:tf.train.Saver类中的save TensorFlow提供了一个一个API来保存和还原一个模型,即tf.train.Saver类.以下代码为保存TensorFlow计算图的方 ...

  10. 一篇文章彻底弄懂Base64编码原理(转载)

    在互联网中的每一刻,你可能都在享受着Base64带来的便捷,但对于Base64的基础原理又了解多少?今天这篇博文带领大家了解一下Base64的底层实现. Base64的由来 目前Base64已经成为网 ...