AtCoder Regular Contest 192 (Div. 2)
A
ARC Arc
AtCoder
⌀ 1387
原题
←B →
翻译中…

Problem Statement

翻译中…

You are given a positive integer $N$ and a sequence $A=(A_1,A_2,\dots,A_N)$ of length $N$, consisting of $0$ and $1$.

翻译中…

We call a string $S$ of length $N$, consisting only of uppercase English letters, a good string if it is possible to perform the following operation any number of times (possibly zero) so that the sequence $A$ contains no $0$. Here, $S_i$ $(1\leq i\leq N)$ denotes the $i$-th character of $S$, and we define $S_{N+1}=S_1$, $S_{N+2}=S_2$, and $A_{N+1}=A_1$.

翻译中…
  • Perform one of the following operations:
  • Choose an integer $i$ with $1\leq i\leq N$ such that $S_i=$ A, $S_{i+1}=$ R, and $S_{i+2}=$ C, and replace each of $A_i$ and $A_{i+1}$ with $1$.
    • Choose an integer $i$ with $1\leq i\leq N$ such that $S_{i+2}=$ A, $S_{i+1}=$ R, and $S_i=$ C, and replace each of $A_i$ and $A_{i+1}$ with $1$.
翻译中…

Determine whether there exists a good string.

翻译中…

Constraints

翻译中…
  • $3\leq N\leq 200000$
  • $A_i\in \lbrace 0,1 \rbrace$ $(1\leq i\leq N)$
  • All input values are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 \dots A_N

翻译中…

Output

翻译中…

If there exists a good string, print Yes; otherwise, print No.

翻译中…

The judge is case-insensitive; for example, if the correct answer is Yes, outputs such as yes, YES, or yEs will also be accepted.

翻译中…

样例

Input #1
12
0 1 0 1 1 1 1 0 1 1 1 0
Output #1
Yes
For example, `RARCARCCRAGC` is a good string. This is because it is possible to change all elements of $A$ to $1$ by performing the following operations: - Initially, $A=(0,1,0,1,1,1,1,0,1,1,1,0)$. - Perform the first operation with $i=2$. Then, $A=(0,1,1,1,1,1,1,0,1,1,1,0)$. - Perform the first operation with $i=5$. Then, $A=(0,1,1,1,1,1,1,0,1,1,1,0)$. - Perform the second operation with $i=8$. Then, $A=(0,1,1,1,1,1,1,1,1,1,1,0)$. - Perform the second operation with $i=12$. Then, $A=(1,1,1,1,1,1,1,1,1,1,1,1)$. Since there exists a good string, output `Yes`.
Input #2
3
0 0 0
Output #2
No
Good strings do not exist.
Input #3
29
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Output #3
Yes
Since $A$ already contains no $0$, every string of length $29$ consisting of uppercase English letters is a good string.
题目信息
题号
arc192_a
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。