UVALive 4222 /HDU 2961 Dance 大模拟
Dance
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.
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.
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
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
* ...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 大模拟的更多相关文章
- HDU 5920 Ugly Problem 高精度减法大模拟 ---2016CCPC长春区域现场赛
题目链接 题意:给定一个很大的数,把他们分为数个回文数的和,分的个数不超过50个,输出个数并输出每个数,special judge. 题解:现场赛的时候很快想出来了思路,把这个数从中间分为两部分,当位 ...
- AC日记——神奇的幻方 洛谷 P2615(大模拟)
题目描述 幻方是一种很神奇的N*N矩阵:它由数字1,2,3,……,N*N构成,且每行.每列及两条对角线上的数字之和都相同. 当N为奇数时,我们可以通过以下方法构建一个幻方: 首先将1写在第一行的中间. ...
- ACdream 1188 Read Phone Number (字符串大模拟)
Read Phone Number Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Sub ...
- 2016ACM-ICPC网络赛北京赛区 1001 (trie树牌大模拟)
[题目传送门] 1383 : The Book List 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 The history of Peking University ...
- Bzoj1972: [Sdoi2010]猪国杀 题解(大模拟+耐心+细心)
猪国杀 - 可读版本 https://mubu.com/doc/2707815814591da4 题目可真长,读题都要一个小时. 这道题很多人都说不可做,耗时间,代码量大,于是,本着不做死就不会死的精 ...
- (大模拟紫题) Luogu P1953 易语言
原题链接:P1953 易语言 (我最近怎么总在做大模拟大搜索题) 分别处理两种情况. 如果只有一个1或0 直接设一个cnt为这个值,每次输入一个新名字之后把数字替换成cnt,最后cnt++即可. 注意 ...
- NOIP2017 时间复杂度 大模拟
再写一道大模拟题. 由于是限时写的,相当于考场代码,乱的一批. 题目链接:P3952 时间复杂度 先记几个教训: 字符串形式的数字比较大小老老实实写函数,字典序都搞错几次了 栈空的时候不但pop()会 ...
- [CSP-S模拟测试]:引子(大模拟)
题目描述 网上冲浪时,$Slavko$被冲到了水箱里,水箱由上而下竖直平面.示意图如下: 数字$i$所在的矩形代表一个编号为$i$的水箱.1号水箱为水箱中枢,有水管连出.除了$1$号水箱外,其他水箱上 ...
- 模拟赛38 B. T形覆盖 大模拟
题目描述 如果玩过俄罗斯方块,应该见过如下图形: 我们称它为一个 \(T\) 形四格拼板 .其中心被标记为\(×\). 小苗画了一个 \(m\) 行 \(n\) 列的长方形网格.行从 \(0\) 至 ...
随机推荐
- ADT、C和Java
<编程导论(Java)·5 链表.数组和栈> 数据抽象使得用户程序猿在编写客户程序时,摆脱该数据类型的实现细节而只关心该数据类型的接口.在计算机科学中.有一些重要的数据抽象--数据结构,应 ...
- Codeforces Round #272 (Div. 2) 题解
Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs time limit per test 1 second memory limit per ...
- Linux 下配置,安装Hadoop
1.从官网上下载hadoop-2.4.1.tar.gz,我的版本为hadoop-2.4.1,可在http://pan.baidu.com/s/1cLAKCQ 下载. 2.解压hadoop-2.4.1. ...
- sdwebimage缓存图片
当使用SDWebImage时,如果用相同图片名的图片替换掉了原始缓存的图片,当再次请求的时候,还是使用的缓存图片,图片不会发生改变 原因:图片在NSCache中是以absolute url作为key存 ...
- caffe study- AlexNet 之算法篇
在机器学习中,我们通常要考虑的一个问题是如何的“以偏概全”,也就是以有限的样本或者结构去尽可能的逼近全局的分布.这就要在样本以及结构模型上下一些工夫. 在一般的训练任务中,考虑的关键问题之一就是数据分 ...
- 基于Socket的Winform例子
一.直接上效果图 二.Socket握手 三.服务端 Thread threadWatch = null;// 负责监听客户端的线程 Socket socketWatch = null;// 负责监听客 ...
- <Android Framework 之路>Android5.1 Camera Framework(三)
上一次讲解了一下startPreview过程,主要是为了画出一条大致的从上到下的线条,今天我们看一下Camera在Framework的sendCommand和dataCallback,这部分属于衔接过 ...
- SQL 学习——简序以及学习路线
1.最近发现自己除去简单的SQL语句好像其他的并不怎么懂哎,虽然暂时是android用不到太复杂点的语句,想来总不能一直这样把, 顺带还是看看Sql. 2.画个图规划下自己的学习路线
- RabbitMQ学习笔记(2)----RabbitMQ简单队列(Hello World)的使用
1. 简单队列结构图 2. 引入依赖 pom.xml文件 <dependency> <groupId>com.rabbitmq</groupId> <arti ...
- 再生龙恢复分区后修复引导或debian linux修复引导 三部曲
先参考 sudo -imkdir /mntmount /dev/sda1 /mntgrub-install --force --no-floppy --root-directory=/mnt /dev ...