博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVALive 4222 /HDU 2961 Dance 大模拟
阅读量:5223 次
发布时间:2019-06-14

本文共 4662 字,大约阅读时间需要 15 分钟。

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 
#include
#include
#include
#include
#include
using namespace std ;typedef long long ll;const int N = 2000000 + 10;const int inf = 1e9 + 7;char a[N];int len,H[N];int check4() { if(len < 6) return 1; char b[10] = { 'j','i','g','g','l','e'}; int cnt = 0; for(int i = 0; i < 6; i++) { if(a[i] != b[cnt]) return 1; cnt++; } return 0;}int check2() { if(len < 15) return 0; char b[30] = { "clap stomp clap"}; int cnt =0 ; for(int i = len - 15; i < len ;i ++) { if(a[i]!=b[cnt++]) return 0; } return 1;}int check5() { for(int i = 0; i < len - 2; i+=1) { if(a[i] == 'd' && a[i+1] == 'i' && a[i+2] == 'p') return 1; } return 0;}int check3() { if(len < 5) return 1; for(int i = 0; i <= len - 5; i++) { if(a[i] == 't' && a[i+1] == 'w' && a[i+2] == 'i' && a[i + 3] == 'r'&&a[i+4]=='l') { for(int i = 0; i < len - 2; i++) { if(a[i] == 'h' && a[i+1] == 'o' && a[i+2] == 'p') return 1; } return 0; } } return 1;}void solve() { memset(H,0,sizeof(H)); vector
ans; len = strlen(a); if(!check2()) H[2] = 1; if(!check3()) H[3] = 1; if(!check4()) H[4] = 1; if( check5() ) { for(int i = 0; i < len - 2; i++) { if(a[i] == 'd' && a[i+1] == 'i' && a[i+2] == 'p') { int f = 1; if(i - 7 >= 0) { int cnt2= 0; for(int j = i - 1; j >= 0 ; j--) { if(a[j] ==' ') cnt2++; if(cnt2 == 2) {cnt2 = j;break;} } if(cnt2 - 6 >= 0) { int flag = 0; char b[20] = { "jiggle"};int cnt = 0; for(int j = cnt2 - 6; j < cnt2; j ++) { if(a[j]!= b[cnt++]) {flag =1;break;} } if(!flag) f = 0; } } if(i - 7 >= 0) { int flag = 0; char b[20] = { "jiggle "};int cnt = 0; for(int j = i - 7; j < i; j ++) { if(a[j]!= b[cnt++]) {flag =1;break;} } if(!flag) f = 0; } if(i + 8 < len) { int flag = 0; char b[20] = { " twirl"};int cnt = 0; for(int j = i + 3; j <= i+8; j ++) { if(a[j]!= b[cnt++]) {flag =1;break;} } if(!flag) f = 0; } if(f) { a[i] = 'D'; a[i+1] = 'I'; a[i+2] = 'P'; H[1] = 1; } i += 2; } } } else H[5] = 1; for(int i = 1; i <= 5; i++) { if(H[i]) ans.push_back(i); } if(!ans.size())cout<<"form ok: "<
<

 

 
 

转载于:https://www.cnblogs.com/zxhl/p/5151892.html

你可能感兴趣的文章
获得一个类的属性
查看>>
共享程序集和强命名程序集
查看>>
正则判断密码强弱
查看>>
包RSNNS-MLP-IRIS-TUNING案例解析
查看>>
day01 温习回顾的学习,从0基础的小白接触python
查看>>
不同屏幕手机 分析
查看>>
【转载】Web 研发模式演变
查看>>
Lucene的概念
查看>>
程序员面试之软件测试面试问答
查看>>
写一个有字符界面的ssh链接工具
查看>>
.net中的反射(转载)
查看>>
Android系统手机指令
查看>>
在ASP.NET中,设置Session的过期时间的方法
查看>>
HttpWebRequest的GetResponse或GetRequestStream偶尔超时 + 总结各种超时死掉的可能和相应的解决办法...
查看>>
状压dpHDU - 4856
查看>>
第一次作业
查看>>
配置EM遇到的问题:*_orcl not found\listener not up\Error creating the repository
查看>>
CentOS忘记root密码解决办法
查看>>
Python开发【字符串格式化篇】
查看>>
tomcat 最大并发数
查看>>