水题 Codeforces Round #306 (Div. 2) A. Two Substrings
/*
水题:遍历一边先找AB,再BA,再遍历一边先找BA,再AB,两种情况满足一种就YES
*/
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <stack>
using namespace std; typedef long long ll;
const int MAXN = 1e5 + ;
const int INF = 0x3f3f3f3f;
char s[MAXN]; int main(void) //Codeforces Round #306 (Div. 2) A. Two Substrings
{
while (scanf ("%s", s) == )
{
bool ok1 = false, ok2 = false, ok3 = false, ok4 = false;
int len = strlen (s); int p = ;
for (int i=; i<len; ++i)
{
if (i < len - && !ok1 && s[i] == 'A' && s[i+] == 'B')
{
ok1 = true; i++;
}
else if (i < len - && ok1 && s[i] == 'B' && s[i+] == 'A')
{
ok2 = true; break;
}
}
for (int i=; i<len; ++i)
{
if (i < len - && !ok3 && s[i] == 'B' && s[i+] == 'A')
{
ok3 = true; i++;
}
else if (i < len - && ok3 && s[i] == 'A' && s[i+] == 'B')
{
ok4 = true; break;
}
} if ((ok1 && ok2) || (ok3 && ok4)) puts ("YES");
else puts ("NO");
} return ;
} /*
ABA
BACFAB
AXBYBXA
*/
水题 Codeforces Round #306 (Div. 2) A. Two Substrings的更多相关文章
- 水题 Codeforces Round #302 (Div. 2) A Set of Strings
题目传送门 /* 题意:一个字符串分割成k段,每段开头字母不相同 水题:记录每个字母出现的次数,每一次分割把首字母的次数降为0,最后一段直接全部输出 */ #include <cstdio> ...
- 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas
题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...
- 水题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas
题目传送门 /* 水题:ans = (1+2+3+...+n) * k - n,开long long */ #include <cstdio> #include <algorithm ...
- 水题 Codeforces Round #303 (Div. 2) A. Toy Cars
题目传送门 /* 题意:5种情况对应对应第i或j辆车翻了没 水题:其实就看对角线的上半边就可以了,vis判断,可惜WA了一次 3: if both cars turned over during th ...
- 水题 Codeforces Round #286 (Div. 2) A Mr. Kitayuta's Gift
题目传送门 /* 水题:vector容器实现插入操作,暴力进行判断是否为回文串 */ #include <cstdio> #include <iostream> #includ ...
- 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root
题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...
- 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table
题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...
- 水题 Codeforces Round #307 (Div. 2) A. GukiZ and Contest
题目传送门 /* 水题:开个结构体,rk记录排名,相同的值有相同的排名 */ #include <cstdio> #include <cstring> #include < ...
- 水题 Codeforces Round #105 (Div. 2) B. Escape
题目传送门 /* 水题:这题唯一要注意的是要用double,princess可能在一个小时之内被dragon赶上 */ #include <cstdio> #include <alg ...
随机推荐
- javascript array-like object
http://www.nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/ ...
- storm的例子,一个非常好的网址
https://insight.io/github.com/apache/storm/tree/HEAD/examples/storm-elasticsearch-examples/src/main/ ...
- 深入理解 C 指针阅读笔记 -- 第六章
Chapter6.h #ifndef __CHAPTER_6_ #define __CHAPTER_6_ /*<深入理解C指针>学习笔记 -- 第六章*/ typedef struct _ ...
- C++开发人脸性别识别教程(8)——搭建MFC框架之读取目录信息
在上一篇博客中我们已经绘制了MFC界面,在这篇博客中我们将加入响应代码,为MFC框架加入一个最主要的功能:打开一个目录. 一.加入相关头文件 这里头文件主要包括三类:opencv头文件.批量读取文件相 ...
- VC++ VS2010 error LNK1123 转换到 COFF 期间失败 怎么办
1 无法输出Hello world 2 点击项目-属性,打开属性页 3 配置属性-清单工具-输入和输出-嵌入清单改成否 4 找出计算机中的所有cvtres.exe,删掉早期的,只留最新版的 ...
- 基于Spring-SpringMVC-Mybatis的简单样例
复习下 好久没搞过撸过代码了! 这个样例包括一个完整的增删改查! 源代码地址http://download.csdn.net/detail/wangdianyong/8909903
- robotframework接口自动化
robot framework框架在测试接口上比soapUI好用的多,在此介绍下get方法的HTTP接口,其实这个接口也是把POST数据作为参数进行get请求,使用post 方法也是一样,一共6步就可 ...
- Selenium系列之--测试框架断言【转】
selenium提供了三种模式的断言:assert .verify.waitfor 1)Assert(断言) 失败时,该测试将终止. 2)Verify(验证) 失败时,该测试将继续执行,并将错误记入日 ...
- JAVA程序员常用软件整理
Java类软件:-------------------------------JDK7.0:http://pan.baidu.com/s/1jGFYvAYMyclipse8.5破解版:http://p ...
- HEX文件格式学习笔记
这也是一篇学习摘抄:原文地址:http://blog.csdn.net/syrchina/article/details/7004998 为了编写一个可以按照自己的要求进行ISP的程序, ...