問題一覧 > 通常問題

No.1082 XOR of XOR

レベル : / AI推定難易度 : 550 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 374
作問者 : tyawanmusi / テスター : 👑 CleyL
お気に入りにしたユーザー ProblemId : 3823 / 自分の提出
問題文最終更新日: 2020-05-22 18:09:22
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 253 (順位表) の他の問題:

Problem Statement

There is a sequence $A$ of non-negative integers with $N$ elements. The $i(1 \le i \le N)$-th element of $A$ is $A_i$.
Chawanmushi-kun performs the following operations.

  • Rearrange $A$ in any order.
  • Create a sequence $B$ of non-negative integers such that $B_j = A_j \oplus A_{j+1} (1 \le j \le N-1)$.
  • Compute $X = B_1 \oplus B_2 \oplus B_3 \oplus \dots \oplus B_{N-1}$.
Find the maximum value of $X$.
Here, $\oplus$ denotes the bitwise XOR.

* If you are not familiar with XOR, please refer to this page.
https://ja.wikipedia.org/wiki/%E6%8E%92%E4%BB%96%E7%9A%84%E8%AB%96%E7%90%86%E5%92%8C

Constraints

  • $2 \le N \le 2 \times 10^3$
  • $0 \le A_i \le 10^9$
  • $N, A_i$ are integers

Input

$N$
$A_1\ A_2\ \dots\ A_N$

The first line ($1$) contains the integer $N$.
The second line ($2$) contains the sequence $A$ of non-negative integers, separated by spaces.

Output

Print the maximum value of $X$ on one line.
End the output with a newline.

Sample

Sample 1
Input
3
11 13 17
Output
28

The possible rearrangements of $A$ are $(11,13,17),(11,17,13),(13,11,17),(13,17,11),(17,11,13),(17,13,11)$.
Among these, when $A$ is $(13,11,17)$, $B$ becomes $(6,26)$ and $X=28$. This is the maximum value of $X$.
Also, when $A$ is $(17,11,13)$, $X=28$ as well.

Sample 2
Input
5
1 1 1 1 1
Output
0

No matter how $A$ is rearranged, $X=0$.

Sample 3
Input
8
47 36 12 71 79 85 81 74
Output
126

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