UVALive - 4222
题目链接:https://vjudge.net/contest/244167#problem/D
题目:
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.
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.
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.
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
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
string str;
int flag[]; int main()
{
while(getline(cin,str))
{
vector<string> vec;
memset(flag,,sizeof(flag));
for(int i=;i<;i++)
vec.clear();
int len=str.length();
string ss;
for(int i=;i<len;i++)
{
if(str[i]!=' ')
{
ss+=str[i];
}
if(str[i]==' '||i==len-)
{
vec.push_back(ss);
ss="";
}
}
//判断条件2
if(str.size()<)
flag[]=;
else
{
string sss=str.substr(str.size()-,);
//cout<<sss<<endl;
if(sss!="clap stomp clap")
flag[]=;
}
//cout<<flag[2]<<endl;
str.clear();
int l=vec.size(),cntdip=,cnthop=,cnttwirl=;
for(int i=;i<l;i++)
{
//cout<<vec[i]<<endl;
if(vec[]=="jiggle") //判断条件4
{
flag[]=;
}
if(vec[i]=="twirl")
cnttwirl++;
if(vec[i]=="hop")
cnthop++;
if(vec[i]=="dip") //判断条件1
{
cntdip++;
int flag1=,flag2=,flag3=;
if(i>=&&vec[i-]=="jiggle")
flag1=;
if(i>=&&vec[i-]=="jiggle")
flag2=;
if(i<=l-&&vec[i+]=="twirl")
flag3=;
if(flag1==&&flag2==&&flag3==) //全都不符合说明是错的
{
flag[]=;
vec[i]="DIP";
}
}
}
if(cnttwirl!=&&cnthop==) //判断条件3
flag[]=;
if(cntdip==) //判断条件5
flag[]=;
int cnt=,k;
for(int i=;i<=;i++)
{
if(flag[i])
{
cnt++;
k=i;
}
}
if(cnt==)
cout<<"form ok: ";
else if(cnt==)
printf("form error %d: ",k);
else
{
int k=;
printf("form errors ");
for(int i=;i<=;i++)
{
if(flag[i])
{
k++;
if(k==cnt-)
printf("%d and ",i);
else if(k==cnt)
printf("%d: ",i);
else
{
printf("%d, ",i);
}
}
}
}
for(int i=;i<l;i++)
{
if(i==)
cout<<vec[i];
else
cout<<" "<<vec[i];
}
cout<<endl;
}
return ;
}
UVALive - 4222的更多相关文章
- UVALive 4222 Dance 模拟题
Dance 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&pag ...
- UVALive 4222 /HDU 2961 Dance 大模拟
Dance Problem Description For a dance to be proper in the Altered Culture of Machinema, it must abid ...
- UVALive - 4108 SKYLINE[线段树]
UVALive - 4108 SKYLINE Time Limit: 3000MS 64bit IO Format: %lld & %llu Submit Status uDebug ...
- UVALive - 3942 Remember the Word[树状数组]
UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...
- UVALive - 3942 Remember the Word[Trie DP]
UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...
- 思维 UVALive 3708 Graveyard
题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...
- UVALive 6145 Version Controlled IDE(可持久化treap、rope)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...
- UVALive 6508 Permutation Graphs
Permutation Graphs Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit ...
- UVALive 6500 Boxes
Boxes Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Pract ...
随机推荐
- python之tips(三)--为什么Python有相同的不可变对象id不同?
参考 : https://www.jianshu.com/p/0f6f0db0ce8f
- 移动端Web界面滚动touch事件
解决办法一: elem.addEventListener( 'touchstart', fn, { passive: false } ); 解决办法二: * { touch-action: pan-y ...
- ansible的playbook简单使用
一.介绍 playbook就是一个用yaml语法把多个模块堆起来的一个文件 核心组件: Hosts:执行的远程主机列表Tasks:任务,由模块定义的操作的列表:Varniables:内置变量或自定义变 ...
- python3 自动识图
一.安装依赖库 pip install pytesseract pip install pillow 二.安装识图引擎tesseract-ocr https://pan.baidu.com/s/1Qa ...
- jenkins插件findbugs+pmd+checkstyle结合sonar与maven(java环境代码质量和代码规范管理)
一.下载jdk并安装(最好jdk官网下载解压安装的) 二.下载maven并安装maven 三.安装jenkins及插件 安装checkstyle.pmd.findbugs.maven.sonar等相关 ...
- Yii2的save()方法容易出错的地方
如果save()返回true, 但是数据没有保存成功,则应该是开启了事务且已经回滚 如果save()返回false, 则使用$model->errors查看错误原因 可以设置$model的场景, ...
- 一、纯css实现顶部进度条随滚动条滚动
一.效果图 二.直接复制粘贴 <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...
- zh-CN、zh-Hans区别
zh-CN:地区限制匹配规范,表示用在中国大陆区域的中文.包括各种大方言.小方言.繁体.简体等等都可以被匹配到. zh-Hans:语言限制匹配规范,表示简体中文.适用区域范围是全宇宙用中文简体的地方, ...
- springboot+jpa+mysql+redis+swagger整合步骤
springboot+jpa+MySQL+swagger框架搭建好之上再整合redis: 在电脑上先安装redis: 一.在pom.xml中引入redis 二.在application.yml里配置r ...
- LODOP直接用base64码输出图片
Lodop中的ADD_PRINT_IMAGE,也可以直接输出base64码图片,不用加img标签,如果加了img标签,会被当做超文本对待,受浏览器引擎解析的影响. 什么时候使用base64码直接输出比 ...