#arc157a. [arc157_a]XXYYX
[arc157_a]XXYYX
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
.
Sample Input 1
5 1 1 1 1
Sample Output 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.
Sample Input 2
5 1 2 1 0
Sample Output 2
Yes
For instance, XXYXY
satisfies the condition.
Sample Input 3
5 0 4 0 0
Sample Output 3
No
No string satisfies the condition.