水题 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 ...
随机推荐
- Meteor在手机上运行
在本章中,我们将学习如何在Android设备上运行你的应用程序.最近Meteor刚刚添加此功能适用于Windows操作系统,所以我们需要更新 Meteor 应用到 1.3测试版. 注 在写的时候本教程 ...
- 聚类算法K-Means, K-Medoids, GMM, Spectral clustering,Ncut
聚类算法是ML中一个重要分支,一般采用unsupervised learning进行学习,本文根据常见聚类算法分类讲解K-Means, K-Medoids, GMM, Spectral cluster ...
- SQL 主机
SQL 主机 SQL 主机 如果您想要您的网站存储数据在数据库并从数据库显示数据,您的 Web 服务器必须能使用 SQL 语言访问数据库系统. 如果您的 Web 服务器托管在互联网服务提供商(ISP, ...
- android-调用系统的ContentPrivder获取单张图片实现剪切做头像及源代码下载
首先讲述这个小项目的特色: 1.调用系统的相冊应用获取单张图片 2.对单张图片进行剪切方便做成指定大小的头像图片 3.对获取图片的结果进行解析,使用三种方式进行. 首先看看效果图: 打开app,进入注 ...
- vi下对齐代码的操作
时不时会用到,但easy忘,在这里记录一下 1. ctrl + v (选中块) 2. ctrl + f (向前) 或 ctrl +v (向后) 3. 按"=", 把选中的代码对齐
- python的序列化和反序列化以及json
python 的序列化和反序列化用于内存之间的共享,包括服务器和客户端的共享,两个Python程序之间的共享,以及以字符串的形式存储到硬盘中. pyhton 的pickle 可以对Python的各种数 ...
- 【java】itoo项目实战之hibernate 懒载入优化性能
在做itoo 3.0 的时候,考评系统想要上线,就開始导入数据了,仅仅导入学生2万条数据,可是导入的速度特别的慢.这个慢的原因是由于导入的时候进行了过多的IO操作.可是导入成功之后,查询学生的速度更加 ...
- windows下使用mingw和msys编译GOTOBLAS和OpenBLAS
在windows下利用msys编译openBLAS若遇到错误提示: gcc: CreateProcess : No such file or directory 问题原因参考:http://www.c ...
- 嵌入式开发之davinci---dm8168VPORT口管脚总结
http://blog.csdn.net/shanghaiqianlun/article/details/7531365
- eclipse中经常使用快捷键
熟练一些快捷键,会使你的开发更加快捷.高效,值得花些时间学一下! 1. ctrl+shift+r:打开资源 这可能是全部快捷键组合中最省时间的了.这组快捷键能够让你打开你的工作区中不论什么一个文件,而 ...