atcoder#ARC157A. [ARC157A] XXYYX
[ARC157A] XXYYX
Score : points
Problem Statement
Determine whether there is a string of length consisting of X
and Y
that satisfies the following condition.
Condition: Among the pairs of consecutive characters in ,
- exactly are
XX
, - exactly are
XY
, - exactly are
YX
, and - exactly are
YY
.
Constraints
Input
The input is given from Standard Input in the following format:
Output
If there is a string that satisfies the condition, print Yes
; otherwise, print No
.
5 1 1 1 1
Yes
For instance, if XXYYX
, the pairs of consecutive characters are XX
, XY
, YY
, and YX
from left to right. Each pattern occurs exactly once, so the condition is satisfied.
5 1 2 1 0
Yes
For instance, XXYXY
satisfies the condition.
5 0 4 0 0
No
No string satisfies the condition.