atcoder#ARC138B. [ARC138B] 01 Generation
[ARC138B] 01 Generation
Score : points
Problem Statement
Snuke is about to make an integer sequence of length consisting of and . He starts with an empty sequence and does the following two kinds of operations times in total, in any order he likes.
- Operation A: Flip every element of , that is, convert each to and vice versa. Then, add to the beginning of .
- Operation B: Add to the end of .
You are given an integer sequence of length consisting of and : . Determine whether it is possible to make equal to .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If it is possible to make equal to , print Yes
; otherwise, print No
.
4
0 1 1 0
Yes
Snuke can do the following.
- Start with
- Do operation A, making .
- Do operation B, making .
- Do operation A, making .
- Do operation B, making .
4
1 0 0 0
No
4
0 0 0 1
No