ZOJ Special AC String 水
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 水的更多相关文章
- [LeetCode] Special Binary String 特殊的二进制字符串
Special binary strings are binary strings with the following two properties: The number of 0's is eq ...
- [Swift]LeetCode761. 特殊的二进制序列 | Special Binary String
Special binary strings are binary strings with the following two properties: The number of 0's is eq ...
- 761. Special Binary String
Special binary strings are binary strings with the following two properties: The number of 0's is eq ...
- 【LeetCode】761. Special Binary String 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/special- ...
- leetcode 761. Special Binary String
761. Special Binary String 题意: 一个符合以下两个要求的二进制串: \(1.串中包含的1和0的个数是相等的.\) \(2.二进制串的所有前缀中1的个数不少于0的个数\) 被 ...
- Searching the String ZOJ - 3228 AC自动机查询升级版
题意:先给你一个不超过1000000长度的大串s:接下来输入一个n代表接下来输入的小串个数,小串长度不超过6. 小串分两种类型0和1类型. 0类型表示小串在大串中的最大匹配个数就是常规的AC自动机的做 ...
- [AC自己主动机] zoj Searching the String
意甲冠军: 到原始字符串.给n字符串,每个字符串都有一个属性,属性0代表重叠,1代表不能重叠 请各多少次出现的字符串 思维: 为了便于建立两台机器自己主动(0一个.1一个) 然后,它可以重叠非常好做, ...
- Detect the Virus ZOJ - 3430 AC自动机
One day, Nobita found that his computer is extremely slow. After several hours' work, he finally fou ...
- ZOJ 3494 (AC自动机+高精度数位DP)
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3494 题目大意:给定一些被禁止的BCD码.问指定范围内不含有 ...
随机推荐
- 漫话Unity(二)
三.Unity编辑器介绍 Unity是一个商业级的3d游戏引擎.一个引擎的专业程度事实上并非体如今它多么牛b 的次世代效果,说实话那些效果即便你会用也不敢用.由于没有哪个手机是次世代的. 游戏引擎的专 ...
- ListView- 最后一行添加控件
今天在做一个功能的时候,要求必须是在一个listview下,有一段提示行的文字,自己的那个listview的adapter用的是cursoradapter,这样的话,处理布局的灵活性就大打折扣了.最开 ...
- Android学习笔记进阶15之Shader渲染
Android提供的Shader类主要是渲染图像以及一些几何图形. Shader有几个直接子类: BitmapShader : 主要用来渲染图像 LinearGradient :用来进行线性渲 ...
- PHP和JSON
PHP和JSON 一.总结 1.php中json的使用方法:php中json的使用超级简单啦,主要是两个函数json_encode(编码)和json_decode(解码),像md5加密 2.json的 ...
- 使用Notepad++的XML Tools插件格式化XML文件
转自“”:https://blog.csdn.net/qq_36279445/article/details/79803310 1. 安装XML Tools插件 (1) 通过网址http://sour ...
- 63.当当网txt数据按行切割与合并
获取文件有多少行 //获取文件有多少行 int getN(char *path) { FILE *pf = fopen(path, "r"); if (pf==NULL) { ; ...
- Catch Me If You ... Can't Do Otherwise--转载
原文地址:https://dzone.com/articles/catch-me-if-you-cant-do-otherwise I don't know whether it's an anti- ...
- [Javascript AST] 4. Continue: Report ESLint error
const disallowedMethods = ["log", "info", "warn", "error", & ...
- Windows Server 2016 上配置 APACHE+SSL+PHP+perl
Windows Server 2016 上配置 APACHE+SSL+PHP+perl 安装环境 谷歌云实例 Windows Server 2016 Apache Apache/2.4.25 (win ...
- 1.15 Python基础知识 - 函数
函数是可重用的程序代码段. 一.函数的声明和调用 声明格式: def 函数名([形参列表]): 函数体 调用格式: 函数名([实参列表]) 函数名:是一种标识符,命名规则为全小写字母,可以使用下划线增 ...