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\) 至 ...
随机推荐
- Ural 1152 False Mirrors(状压DP)
题目地址:space=1&num=1152">Ural 1152 初学状压DP,原来状压仅仅是用到了个位运算.. 非常水的状压DP.注意四则运算的优先级是高于位运算的..也就是 ...
- SOA概念具体解释
1.概述 1.1基本定义 SOA(Service-Oriented Architecture)既面向服务的体系结构,是一个组件模型.它将应用程序猿的不同功能可是(称为服务)通过定义良好的接口联系起来. ...
- Project Euler:Problem 37 Truncatable primes
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remo ...
- JavaScript(js)对象常用操作,JS操作JSON总结
数据类型判断可以通过一元操作符typeof,此操作符可以判断大部分JS数据类型. 也可以通过instanceof来判断.如: var a = []; alert(typeof a); // objec ...
- elasticsearch源码分析之search模块(client端)
elasticsearch源码分析之search模块(client端) 注意,我这里所说的都是通过rest api来做的搜索,所以对于接收到请求的节点,我姑且将之称之为client端,其主要的功能我们 ...
- Caffe C++API 提取任意一张图片的特征系列二----MemoryData
介绍一种更加灵活的方法,用MemoryData层输入数据,可以直接用opencv接口读入我们的图片再添加的网络中. 第一个问题:仍然是工程建立问题,提示卷积层或其他层没有注册,解决方法与上一篇博客一 ...
- Pycharm使用入门
Python安装与Pycharm使用入门 一.安装Python 1.Linux下安装 一般系统默认已安装2.6.6版本,升级成2.7版本, 但 2.6 不能删除,因为系统对它有依赖,epel源里最新的 ...
- SpringBoot项目部署
项目背景 个人博客:http://www.huangyichun.cn/blog/8 采用SpringBoot开发的个人博客,部署到腾讯云服务器上,服务器系统为ubuntu16.04, ...
- javascript中常用数组方法详细讲解
javascript中数组常用方法总结 1.join()方法: Array.join()方法将数组中所以元素都转化为字符串链接在一起,返回最后生成的字符串.也可以指定可选的字符串在生成的字符串中来分隔 ...
- UWP Control Toolkit Collections 求UWP工作
1. it is like wechat wait-sliderdeleteitem in iOS 看起来比较像微信删掉项 now support listview and gridview in C ...