Codeforces Round #306 (Div. 2)_A
来源:互联网 发布:淘宝联盟如何招代理 编辑:程序博客网 时间:2024/05/22 03:02
每日必水系列~
注意 ABACCCCAB 这类情况
感觉自己做的有些麻烦 应该有简单的方法
#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int MAX = 100100;char data[MAX];int pos1[MAX / 2][2];int pos2[MAX / 2][2];void get_turn(char data[]){ int len = strlen(data); for(int i = 0 ; i < len/2 ; i ++) { char tmp = data[i]; data[i] = data[len-1-i]; data[len-1-i] = tmp; }}/** 0 1 2 3 4 5 6 len = 7 len - 1 - i A B A A A B A bug CCCCCCABACCCCCABC**/int main(){ while(~scanf("%s",data)) { memset(pos1,0,sizeof(pos1)); memset(pos2,0,sizeof(pos2)); int len = strlen(data),flag1 = 0,flag2 = 0,num1 = 0; for(int i = 0 ; i < len ; i ++) { if(data[i] == 'A') { if(data[i+1] == 'B') { flag1 = 1; pos1[num1][0] = i; pos1[num1][1] = i+1; num1 ++; } } } get_turn(data); int num2 = 0; for(int i = 0 ; i < len ; i ++) { if(data[i] == 'A') { if(data[i+1] == 'B') { flag2 = 1; pos2[num2][0] = len - i - 1; pos2[num2][1] = len - i - 2; num2 ++; } } } int flag3 = 0; if(flag1 == 1 && flag2 == 1) for(int i = 0 ; i < num1 ;i ++) { for(int j = 0 ; j < num2 ; j ++) { if(pos1[i][0] != pos2[j][0] && pos1[i][1] != pos2[j][1] ) { printf("YES\n"); flag3 = 1; break; } } if(flag3 == 1) break; } if(flag3 == 0) printf("NO\n"); } return 0;}
0 0
- Codeforces Round #306 (Div. 2)_A
- Codeforces Round #305 (Div. 2)_A
- Codeforces Round #328 (Div. 2)_A. PawnChess
- Codeforces Round #331 (Div. 2) _A. Wilbur and Swimming Pool
- Round #232 (Div. 2)_A
- Codeforces Round #254_A
- CF_Educational Codeforces Round 28_A
- Codeforces Round #306 (Div. 2)
- Codeforces Round #306 (Div. 2)
- Codeforces Round #306 (Div. 2)
- Codeforces Round #306 (Div. 2)
- Codeforces Round #306 (Div. 2)
- Codeforces Round #306 (Div. 2)
- Codeforces Round #306 (Div. 2) A
- Codeforces Round #306 (Div. 2) B
- Codeforces Round #306 (Div. 2) C
- Codeforces Round #306 div 2 solution
- Codeforces Round #306 (Div. 2) A
- Java DecimalFormat的主要功能及使用方法
- 总结:用一个例子包含c++的所有的基本知识点(一)
- 关于PhoneGap的7件事
- 程序员应该知道的11句话
- Google 2015 I/O大会为我们带来了什么?
- Codeforces Round #306 (Div. 2)_A
- Python基础:15私有化
- 报表系统结构优化之中间数据外置
- 11. Container With Most Water
- 面试经历一:百度电二面
- Java TreeMap 介绍和使用
- ios客户端学习-AFNetWoriking
- 弹出层局部刷新 AJAX
- 《大话设计模式》--简历复印--原型模式<Prototype>(9)