coderforce 550A. Two Substrings
来源:互联网 发布:jabra elite sport软件 编辑:程序博客网 时间:2024/06/06 01:30
题意:如果字符串中有AB且有BA,而且他们的位置不重合,就输出YES,否则NO。
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;const int maxm=1e5+10;char s[maxm];int main(){ while(scanf("%s",s)!=EOF) { int len=strlen(s); int ok1=0,ok2=0,ok3=0; int ok=0; for(int i=0; i<len-1; i++) { if(!ok1) { if((s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='A')||(s[i]=='B'&&s[i+1]=='A'&&s[i+2]=='B')) { ok1=1; i+=2; continue; } } if(s[i]=='A'&&s[i+1]=='B') { ok2=1; i++; } if(s[i]=='B'&&s[i+1]=='A') { ok3=1; i++; } if((ok2&&ok3)||((ok2||ok3)&&ok1)) { ok=1; break; } } if(ok) { printf("YES\n"); } else { printf("NO\n"); } } return 0;}
1 0
- coderforce 550A. Two Substrings
- Codeforces-550A-Two Substrings
- 【codeforces 550A】Two Substrings
- Coderforce 602A Two Bases
- CodeForces 550A Two Substrings(模拟)
- CodeForces 550A Two Substrings 简单题
- A. Two Substrings
- codefotces #306 A 550A A. Two Substrings(枚举)
- coderforce 519D A and B and Interesting Substrings
- CodeForces NO.550A Two Substrings(特AABAAB)
- coderforce Codeforces Round #333 (Div. 1) A. The Two Routes
- Codeforces,306DIV.2A. Two Substrings
- CF#306- A - Two Substrings-水题
- Two Substrings
- Two Substrings
- Two Substrings
- Two Substrings
- Two Substrings
- (转载)Deep Learning(深度学习)学习笔记整理系列之(三)
- 4.3 - Maya Commands: Errors and Warnings
- 数据包的解析程序
- PriorityQueue优先级队列
- benchmark
- coderforce 550A. Two Substrings
- SSL 之数字签名
- android如音符般的震动
- 编译原理小结——字符和字符串之间的游戏
- (转载)Deep Learning(深度学习)学习笔记整理系列之(四)
- MEMS传感器
- redhat的bugdb
- 静态库和动态库的区别
- dubbo学习笔记