http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3702

题目大意:

对于给定的一个字符串,满足如下要求输出AC,否则WA(好吧我简写)

给定字符串只有ZOJ三个字母组成。Z和J只能有一个并且Z在左边

J之后的O个数必须大于Z之前的O个数

Z和J之间O的个数必须不大于J之后的O的个数,并且他们都大于0

#include<cstdio>
#include<cstring>
const int MAXN=1001;
bool ok(char a[])
{
int len=strlen(a);
int z,j;
z=j=-1;
for(int i=0;i<len;i++)
{
if( a[i]!='Z' && a[i] !='O' && a[i] != 'J')
return false; if(a[i]=='Z' && z==-1) //把右边的z排除
z=i;
else if(a[i]=='Z' && z!=-1)
return false; if(a[i]=='J' && j==-1) //把右边的j排除
j=i;
else if(a[i]=='J' && j!=-1)
return false;
} if(j < z) //j在z左边显然不行
return false; if(z+1==j) //中间没有O
return false; if(j-z-1 > len-1-j)
return false;
if(z > len-1-j)
return false;
//o z o j o o
//0 1 2 3 4 5 6 return true;
}
int main()
{
char a[MAXN];
while(~scanf("%s",a))
{
if(ok(a))
printf("Accepted\n");
else
printf("Wrong Answer\n");
}
}

ZOJ Special AC String 水的更多相关文章

  1. [LeetCode] Special Binary String 特殊的二进制字符串

    Special binary strings are binary strings with the following two properties: The number of 0's is eq ...

  2. [Swift]LeetCode761. 特殊的二进制序列 | Special Binary String

    Special binary strings are binary strings with the following two properties: The number of 0's is eq ...

  3. 761. Special Binary String

    Special binary strings are binary strings with the following two properties: The number of 0's is eq ...

  4. 【LeetCode】761. Special Binary String 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/special- ...

  5. leetcode 761. Special Binary String

    761. Special Binary String 题意: 一个符合以下两个要求的二进制串: \(1.串中包含的1和0的个数是相等的.\) \(2.二进制串的所有前缀中1的个数不少于0的个数\) 被 ...

  6. Searching the String ZOJ - 3228 AC自动机查询升级版

    题意:先给你一个不超过1000000长度的大串s:接下来输入一个n代表接下来输入的小串个数,小串长度不超过6. 小串分两种类型0和1类型. 0类型表示小串在大串中的最大匹配个数就是常规的AC自动机的做 ...

  7. [AC自己主动机] zoj Searching the String

    意甲冠军: 到原始字符串.给n字符串,每个字符串都有一个属性,属性0代表重叠,1代表不能重叠 请各多少次出现的字符串 思维: 为了便于建立两台机器自己主动(0一个.1一个) 然后,它可以重叠非常好做, ...

  8. Detect the Virus ZOJ - 3430 AC自动机

    One day, Nobita found that his computer is extremely slow. After several hours' work, he finally fou ...

  9. ZOJ 3494 (AC自动机+高精度数位DP)

    题目链接:  http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3494 题目大意:给定一些被禁止的BCD码.问指定范围内不含有 ...

随机推荐

  1. InstallShield详细制作说明(二)

    四.设置安装的组件Component

  2. JXNU 新生选拔赛

    1001 最小的数 Problem Description 定义一种正整数集合K,集合中有N个数,集合中元素Ki(1<=i<=N)是包含i个不同质因子的最小的数.因为Ki可能会很大,所以将 ...

  3. 【agc014d】Black and White Tree

    又是被虐的一天呢~(AC是不可能的,这辈子不可能AC的.做题又不会做,就是打打暴力,才能维持骗骗分这样子.在机房里的感觉比回家的感觉好多了!里面个个都是大佬,个个都是死宅,我超喜欢在里面的!) (↑以 ...

  4. 洛谷 P1032 字符变换

    洛谷 P1032 字符变换 题目描述 已知有两个字串 A,B 及一组字串变换的规则(至多 6 个规则): A1​ -> B1​ A2​ -> B2​ 规则的含义为:在 A 中的子串 A1​ ...

  5. 【习题 7-6 UVA - 12113】Overlapping Squares

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 先预处理出来一个正方形. 然后每次枚举新加的正方形左上角的坐标就可以. 注意覆盖的规则,控制一下就可以. 然后暴力判断是否相同. 暴 ...

  6. Rotation--控件位置旋转

    今天想要完成一个按钮的动画,也就是随着手势在屏幕上的滑动,让按钮图片跟着旋转.刚开始的思路是,先把图片旋转以后,在把这个图片设置为imagebutton的背景.不过,会发现这个图片经过处理以后一直变形 ...

  7. PythonNET网络编程4

    本地套接字 Linux 文件 b(块设备文件) c(字符设备文件) d(目录) -(普通文件) l(链接) s(套接字) p(管道) 作用:用于本地不同的程序间进行通信 创建流程 创建本地套接字 so ...

  8. [RxJS] Avoid mulit post requests by using shareReplay()

    With the shareReplay operator in place, we would no longer fall into the situation where we have acc ...

  9. Redis实现Mybatis的二级缓存

    一.Mybatis的缓存 通大多数ORM层框架一样,Mybatis自然也提供了对一级缓存和二级缓存的支持.一下是一级缓存和二级缓存的作用于和定义. 1.一级缓存是SqlSession级别的缓存.在操作 ...

  10. 在react底下安装环境

    1.在react底下安装环境 Image.png Image.png 2.新建一个文件夹 Image.png 3.配置入口文件redux:staticRoot+'/redux/app' Image.p ...