問題一覧 > 通常問題

No.2490 Escalator

レベル : / AI推定難易度 : 2900 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 5
作問者 : ytqm3 / テスター : Cyanmond keisuke6
お気に入りにしたユーザー ProblemId : 10203 / 自分の提出
問題文最終更新日: 2023-10-01 15:10:17
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
yukicoder contest 406 技術室奥プログラミングコンテスト#7 Day2 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。