ZOJ Special AC String 水
来源:互联网 发布:做淘宝外网站赚钱吗 编辑:程序博客网 时间:2024/06/09 21:48
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) //中间没有Oreturn 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 6return 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 水
- ZOJ Special AC String
- zoj 3228 Searching the String【ac自动机】
- ZOJ 3228 Searching the String(AC自动机)
- ZOJ 3228 Searching the String(AC自动机)
- zoj -- 3228 Searching the String(AC自动机)
- ZOJ - 3228 Searching the String (AC自动机)
- [AC自动机] zoj Searching the String
- zoj 3228 Searching the String(AC自动机)
- ZOJ 3228 Searching the String AC自动机
- zoj 3228 Searching the String (ac自动机)
- zoj 3228 Searching the String 【AC自动机】
- ZOJ 3228 Searching the String(AC自动机)
- Special Special Judge III ZOJ
- ZOJ 3349 Special Subsequence
- zoj 3535 Gao the String II(ac自动机+dp)
- zoj 3535 Gao the String II(AC自动机+DP)
- [ZOJ 3784 String of Infinity] AC自动机+Tarjan
- HDU4252:A Famous City
- android中的自动提示框AutoCompleteTextView
- 顺其自然,保持豁达的心态
- Android Java计算时间差
- PHP地区四级联动(thinkphp)
- ZOJ Special AC String 水
- cocos2dx中lua实现继承详解
- OC之【NSMutableArray的使用】
- 引用计数
- MVC 模型项目查找内容总结
- CentOS Redhat RHEL Fedora Ubuntu Debian 各系统简易说明
- UIScrollView
- javascript闭包理解
- 解决Eclipse无法打开“Failed to load the JNI shared library”