問題一覧 > 通常問題

No.1717 Levi-Civita Triangle

レベル : / AI推定難易度 : 2150 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 81
作問者 : zkou / テスター : nok0 Kite_kuma ygussany
お気に入りにしたユーザー ProblemId : 6619 / 自分の提出
問題文最終更新日: 2021-10-10 01:02:59
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 319 (順位表) の他の問題:

Problem Statement

You are given a sequence $(A_1, A_2, \ldots, A_{2N+1})$ of length $2N + 1$ consisting of $0$, $1$, $2$. Apply the following operation to this sequence $N$ times.

  • Replace the original sequence with a new sequence whose length is shorter by $2$. Let $P_i$ and $Q_i$ be the $i$-th elements of the old sequence and the new sequence, respectively. Then, $Q_i$ is determined by the following rule.
$$ Q_i = \begin{cases} 1 & ((P_i, P_{i+1}, P_{i+2}) \in \{(0, 1, 2), (1, 2, 0), (2, 0, 1)\}) \\ 2 & ((P_i, P_{i+1}, P_{i+2}) \in \{(2, 1, 0), (1, 0, 2), (0, 2, 1)\}) \\ 0 & (\mathrm{otherwise}) \end{cases} $$ The final sequence consists of $1$ element. Print that element.

Constraints

  • All inputs are integers.
  • $1 \le N \le 10^5$
  • $0 \le A_i \le 2$ $(1 \le i \le 2N + 1)$

Input

The input is given from standard input in the following format.
$N$
$A_1$ $A_2$ $\cdots$ $A_{2N+1}$

Output

The final sequence consists of $1$ element. Print that element.

Sample

Sample 1
Input
1
0 1 2
Output
1

Sample 2
Input
2
1 2 0 2 1
Output
2

Sample 3
Input
3
0 1 2 2 0 1 0
Output
0

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。