CF550A.Two Substrings

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given string ss . Your task is to determine if the given string ss contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).

输入格式

The only line of input contains a string ss of length between 11 and 10510^{5} consisting of uppercase Latin letters.

输出格式

Print "YES" (without the quotes), if string ss contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise.

输入输出样例

  • 输入#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".

首页