Universal Cup Judging System

Universal Cup

حد الوقت: 1.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100
الإحصائيات

給定一個長度為 $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.