水题 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 ...
随机推荐
- 《Spring设计思想》AOP设计基本原理
0.前言 Spring 提供了AOP(Aspect Oriented Programming) 的支持, 那么,什么是AOP呢?本文将通过一个另外一个角度来诠释AOP的概念,帮助你更好地理解和使用Sp ...
- 白话空间统计之四:P值和Z值(上):零如果
本来今天想要讲讲软件操作的,后来发现好像还有好几个重要的指标没有说,干脆等所有说完在讲操作吧.否则操作出来的结果会发现大量的"不明觉厉". 首先是空间统计里面非常神奇的两个值:P值 ...
- Android TextView设置个别字体样式
TextView进一步深化: Textview 能够对其文字进行格式化. 通过查询资料,了解到格式化文字的方式主要分为两大类: 第一类:HTML标签格式化文字 代码 ...
- LeetCode 168 Excel Sheet Column Title(Excel的列向表标题)
翻译 给定一个正整数,返回它作为出如今Excel表中的正确列向标题. 比如: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 - ...
- shutdown abort模式丢失redo,使用隐含參数启库
shutdown abort模式 丢失redo log 无法open数据库 通过告警报错ORA-00354: corrupt redo log block header 从该错误能够看出当前日志的re ...
- CSS中:overflow:hidden的作用
功能1.隐藏溢出 在IE6下,当子容器的宽高超出父容器时,父容器就会被撑开来. 要想解决这个问题,在父容器中除定义宽和高的值以外,还必须写overflow:hidden,这样就能把子容器的其它内容隐 ...
- NHibernate不支持复杂的linq,就一定要用DataTable这么低级吗
有些linq,好不容易写出来,正想扬眉吐屁一番,不料用NHibernate一执行,却报错,说是不支持,我靠. 只好捏着鼻子写一大段sql,交给它.这种直接执行SQL的情况,我看我同事写的,全部都是返回 ...
- 2016/05/25 Ajax 跨域 转
起因: 起因是这样的,为了复用,减少重复开发,单独开发了一个用户权限管理系统,共其他系统获取认证与授权信息,暂且称之为A系统:调用A系统以B为例.在B系统 中用ajax调用A系统系统的接口(数据格式为 ...
- Cordova打包vue项目(Android)
准备工作: 安装好必要环境: vue-cli,webpack,node.js,android环境 (http://cordova.axuer.com/docs/zh-cn/latest/guide/p ...
- linux epoll的实现原理
1 linux的poll操作 linux文件的poll操作有两个主要目的:第一,主动查看该文件上是否有读写事件:第二,提供操作waitqueue的接口给epoll等上层接口使用,比如epoll可以通过 ...