atcoder#ARC141F. [ARC141F] Well-defined Abbreviation
[ARC141F] Well-defined Abbreviation
Score : points
Problem Statement
You are given srings consisting of A
, B
, C
, D
.
Consider the operation below on a string consisting of A
, B
, C
, D
.
- Repeat the following until contains none of the strings as a substring.- Choose an and one of its occurrences in , remove that occurrence from , and concatenate the remaining parts.
- Choose an and one of its occurrences in , remove that occurrence from , and concatenate the remaining parts.
What is a substring?
A substring of a string is its contiguous subsequence. For example,A
, AB
, and BC
are substrings of ABC
, while BA
and AC
are not.
Determine whether a bad string exists.
Constraints
- if .
- is a string consisting of
A
,B
,C
,D
.
Input
Input is given from Standard Input in the following format:
Output
If a bad string exists, print Yes
.
Otherwise, print No
.
3
A
B
C
No
The only string we can get from is what remains after removing all occurrences of A
, B
, C
from .
1
ABA
Yes
For example, from ABABA
, we can get two strings: AB
and BA
, so is a bad string.
4
CBA
ACB
AD
CAB
Yes