No.2490 Escalator
問題文最終更新日: 2023-10-01 15:10:17
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
Problem Statement
You are given an integer sequence $A=(A_0,A_1,\ldots,A_{2N-1})$ of length $2N$.
Determine whether there exists an integer sequence $B=(B_0,B_1,\ldots,B_{2N-1})$ of length $2N$ satisfying the following conditions.
For all $i$, if $A_i \neq -1$, then $A_i=B_i$.
There exists a pair of integers $(s,t)$ such that $B_{(s+i)\bmod {2N}}=B_{(t-i)\bmod {2N}}$ holds for $0 \le i < N$.
(Original proposer: keisuke6)
Input
$N$
$A_0$ $A_1$ $\ldots$ $A_{2N-1}$
- $1 \le N \le 5 \times 10^4$
- $A_i=-1$ or $1 \le A_i \le 2N$
- All input values are integers.
Output
Print Yes if such a sequence exists, and No otherwise.
Sample
Sample 1
Input
2 1 -1 2 -1
Output
Yes
Taking $B=(1,2,2,1)$ satisfies the conditions.
Sample 2
Input
2 1 2 3 4
Output
No
Sample 3
Input
4 1 2 7 4 1 8 -1 3
Output
No
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
keisuke6