atcoder#ARC145A. [ARC145A] AB Palindrome
[ARC145A] AB Palindrome
Score : points
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?
T$$$$i$$$$1 \le i \le |T|$$$$i$$$$i$$$$|T|$$$$TConstraints
- is a string of length consisting of
AandB.
Input
Input is given from Standard Input in the following format:
Output
If can be turned into a palindrome, print Yes; otherwise, print No.
3
BBA
Yes
Replacing the -nd and -rd characters, BA, with AB will turn into BAB, a palindrome.
4
ABAB
No
No sequence of operations can turn into a palindrome.