CF550A.Two Substrings
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
给你一个字符串 s。你的任务是判断给定的字符串 s 是否包含两个不重叠的子串 "AB" 和 "BA"(这两个子串的出现顺序可以任意)。
输入格式
The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters.
输入仅有一行,包含一个字符串 s,其长度在 1 到 105 之间,且仅由大写拉丁字母组成。
输出格式
Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise.
如果字符串 s 中包含两个不重叠的子串 "AB" 和 "BA",则输出 "YES"(不带引号);否则输出 "NO"。
输入输出样例
输入#1
ABA
输出#1
NO
输入#2
BACFAB
输出#2
YES
输入#3
AXBYBXA
输出#3
NO
说明/提示
In the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".
In the second sample test there are the following occurrences of the substrings: BACFAB.
In the third sample test there is no substring "AB" nor substring "BA".
在第一个样例测试中,尽管存在子串 “AB” 和 “BA”,但它们的出现位置重叠,因此答案为 “NO”。
在第二个样例测试中,子串的出现情况如下:BACFAB。
在第三个样例测试中,既不存在子串 “AB”,也不存在子串 “BA”。
输入解题思路,AI测评打分。不知道怎么写?