大和証券プログラミングコンテスト2022 Spring (AtCoder Regular Contest 138)
翻译中…
Problem Statement
翻译中…
Snuke is about to make an integer sequence of length $N$ consisting of $0$ and $1$. He starts with an empty sequence $x$ and does the following two kinds of operations $N$ times in total, in any order he likes.
翻译中…
- Operation A: Flip every element of
$x$, that is, convert each$0$to$1$and vice versa. Then, add$0$to the beginning of$x$. - Operation B: Add
$0$to the end of$x$.
翻译中…
You are given an integer sequence of length $N$ consisting of $0$ and $1$: $A=(A_1,A_2,\cdots,A_N)$. Determine whether it is possible to make $x$ equal to $A$.
翻译中…
Constraints
翻译中…
$1 \leq N \leq 2 \times 10^5$$0 \leq A_i \leq 1$- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
A_1 A_2 \cdots A_N
翻译中…
Output
翻译中…
If it is possible to make $x$ equal to $A$, print Yes; otherwise, print No.
翻译中…
样例
Input #1
4
0 1 1 0
Output #1
Yes
Snuke can do the following.
- Start with $x=()$
- Do operation A, making $x=(0)$.
- Do operation B, making $x=(0,0)$.
- Do operation A, making $x=(0,1,1)$.
- Do operation B, making $x=(0,1,1,0)$.
Input #2
4
1 0 0 0
Output #2
No
Input #3
4
0 0 0 1
Output #3
No
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。