Universal Cup Judging System

Universal Cup

Límite de tiempo: 1.0 s Límite de memoria: 1024 MB Puntuación total: 100
Estadísticas

畀定一個長度為 $2^n$ 嘅陣列 $a_0, a_1, \dots, a_{2^n-1}$。對於一個長度為 $n$、字符集為 0、1、? 嘅字串 $q$(下標由 1 開始),定義「廣義子集和」$S(q)$ 為符合以下條件嘅所有下標 $j$ 對應嘅 $a_j$ 之和:

  • 對於每個 $1 \le k \le n$,如果 $q_k = \texttt{0}$,咁 $j$ 嘅第 $k$ 個位元係 $0$。
  • 對於每個 $1 \le k \le n$,如果 $q_k = \texttt{1}$,咁 $j$ 嘅第 $k$ 個位元係 $1$。
  • 如果 $q_k = \texttt{?}$,咁對 $j$ 嘅第 $k$ 個位元無任何限制。

例如,當 $n = 3$ 且 $q = \texttt{0?1}$ 嗰陣,廣義子集和係 $S(q) = a_4 + a_6$(二進制分別係 $\texttt{100}$ 同 $\texttt{110}$)。請注意,第一個位元係最低位。

你嘅任務係對每一個長度為 $n$、字符集為 0、1、? 嘅字串計算佢嘅廣義子集和。因為總輸出可能會好大,你只需要輸出呢啲總和全部做按位異或(bitwise XOR)之後嘅結果。

輸入格式

輸入嘅第一行包含一個整數 $n$($1 \le n \le 16$)。

輸入嘅第二行包含 $2^n$ 個整數 $a_0, a_1, \dots, a_{2^n-1}$($0 \le a_i \le 9$),代表陣列 $a$ 入面嘅內容。

輸出格式

輸出一個整數,代表所有廣義子集和嘅按位異或值。

範例

範例輸入 1

1
3 5

範例輸出 1

14

範例輸入 2

2
2 6 8 8

範例輸出 2

0

提示

以下係範例 2 入面各個查詢字串 $q$ 同佢哋對應嘅廣義子集和 $S(q)$:

  • $q = \texttt{00}, S(q) = a_0 = 2$
  • $q = \texttt{10}, S(q) = a_1 = 6$
  • $q = \texttt{?0}, S(q) = a_0 + a_1 = 2 + 6 = 8$
  • $q = \texttt{01}, S(q) = a_2 = 8$
  • $q = \texttt{11}, S(q) = a_3 = 8$
  • $q = \texttt{?1}, S(q) = a_2 + a_3 = 16$
  • $q = \texttt{0?}, S(q) = a_0 + a_2 = 10$
  • $q = \texttt{1?}, S(q) = a_1 + a_3 = 14$
  • $q = \texttt{??}, S(q) = a_0 + a_1 + a_2 + a_3 = 24$

而家好容易驗證輸出係 $0$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.