题目传送门

 /*
水题:遍历一边先找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的更多相关文章

  1. 水题 Codeforces Round #302 (Div. 2) A Set of Strings

    题目传送门 /* 题意:一个字符串分割成k段,每段开头字母不相同 水题:记录每个字母出现的次数,每一次分割把首字母的次数降为0,最后一段直接全部输出 */ #include <cstdio> ...

  2. 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas

    题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...

  3. 水题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas

    题目传送门 /* 水题:ans = (1+2+3+...+n) * k - n,开long long */ #include <cstdio> #include <algorithm ...

  4. 水题 Codeforces Round #303 (Div. 2) A. Toy Cars

    题目传送门 /* 题意:5种情况对应对应第i或j辆车翻了没 水题:其实就看对角线的上半边就可以了,vis判断,可惜WA了一次 3: if both cars turned over during th ...

  5. 水题 Codeforces Round #286 (Div. 2) A Mr. Kitayuta's Gift

    题目传送门 /* 水题:vector容器实现插入操作,暴力进行判断是否为回文串 */ #include <cstdio> #include <iostream> #includ ...

  6. 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root

    题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...

  7. 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table

    题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...

  8. 水题 Codeforces Round #307 (Div. 2) A. GukiZ and Contest

    题目传送门 /* 水题:开个结构体,rk记录排名,相同的值有相同的排名 */ #include <cstdio> #include <cstring> #include < ...

  9. 水题 Codeforces Round #105 (Div. 2) B. Escape

    题目传送门 /* 水题:这题唯一要注意的是要用double,princess可能在一个小时之内被dragon赶上 */ #include <cstdio> #include <alg ...

随机推荐

  1. 【Todo】秒杀系统 & 乐观锁 & Nginx反向代理

    http://www.csdn.net/article/2014-11-28/2822858 1. 单点帐号验证,不用读,而是用写入,Redis,看是否加watch 2. 抢宝的最终购买冲突.包装称“ ...

  2. CentOS5 忘记root密码的解决办法

    方法/步骤   1 开机启动的时候,按“E”进入如下界面. 2 选择相应的内核,再次按“E”,出现下图,选择第二项,再次按“E”键 3 在尾部加:“空格+single”(如图),Enter.图如下: ...

  3. react-document-title

    根据不同的路由改变文档的title 使用该组件: import ReactDocumentTitle from 'path/ReactDocumentTitle' render() { return ...

  4. 工作总结 js 选择器选择多条元素 支持一起设置他们属性 $("#edumes input[type='radio']").prop("checked", false);

    $("#edumes input[type='radio']").prop("checked", false); $("#edumes input[t ...

  5. hdu 3183 A Magic Lamp 贪心

    #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm& ...

  6. EXTJS 4 树形表格组件使用演示样例

    EXTJS 4 树形表格组件使用演示样例 一.总体效果图 version=1&modificationDate=1412058826000&api=v2" alt=" ...

  7. c语言实现输出一个数的每一位

    比方输入1234.在屏幕上打印出1 2 3 4 代码展示: 方法一: #define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #includ ...

  8. 鉴权应用服务器 app客户端 web服务端 安全令牌(SecurityToken)、临时访问密钥(AccessKeyId, AccessKeySecret)

    设置EndPoint和凭证 移动终端是一个不受信任的环境,把AccessKeyId和AccessKeySecret直接保存在终端用来加签请求,存在极高的风险.建议只在测试时使用明文设置模式,业务应用推 ...

  9. SQL外键的作用

    貌似很有用,但没有真正用过: SQL的主键和外键的作用: 外键取值规则:空值或参照的主键值. (1)插入非空值时,如果主键表中没有这个值,则不能插入. (2)更新时,不能改为主键表中没有的值. (3) ...

  10. leetcode 660. Remove 9

    Start from integer 1, remove any integer that contains 9 such as 9, 19, 29... So now, you will have ...