#arc145a. [arc145_a]AB Palindrome
[arc145_a]AB Palindrome
Problem Statement
You are given a string of length consisting of A
and B
.
You can repeat the following operation zero or more times:
- choose a pair of adjacent characters in and replace them with
AB
.
Determine whether can be turned into a palindrome.
What is a palindrome? A string is a palindrome if and only if, for every integer (), the -th character from the beginning and the -th character from the end are the same, where is the length of .
Constraints
- is a string of length consisting of
A
andB
.
Input
Input is given from Standard Input in the following format:
Output
If can be turned into a palindrome, print Yes
; otherwise, print No
.
Sample Input 1
3
BBA
Sample Output 1
Yes
Replacing the -nd and -rd characters, BA
, with AB
will turn into BAB
, a palindrome.
Sample Input 2
4
ABAB
Sample Output 2
No
No sequence of operations can turn into a palindrome.