atcoder#AGC055B. [AGC055B] ABC Supremacy
[AGC055B] ABC Supremacy
Score : points
Problem Statement
You are given a string of length , consisting of A
, B
, and C
.
You are allowed to perform the following operation any number of times:
- Choose any with , such that is equal to
ABC
,BCA
, orCAB
. Then, replace the three characters withABC
,BCA
, orCAB
.
For example, you can perform the following transformations with string AABC
:
AABC
ABCA
BCAA
Determine if you can obtain string from string with some finite (maybe zero) number of operations above.
Constraints
- is a string of length consisting of
A
,B
, andC
. - is a string of length consisting of
A
,B
, andC
.
Input
Input is given from Standard Input in the following format:
Output
If you can transform into with the operations above, output YES
, otherwise output NO
.
The checker is case-insensitive: you can use either uppercase or lowercase letters.
4
AABC
BCAA
YES
This example was explained in the statement.
4
ABCA
BCAB
NO