#arc173e. E - Rearrange and Adjacent XOR
E - Rearrange and Adjacent XOR
Score: points
问题陈述
给定一个由 个非负整数组成的序列 。考虑对这个序列执行以下操作 次,以获得长度为 的序列:
- 设 为 的长度。首先,你可以随意重新排列 中的元素。然后,用一个由 个非负整数组成的序列 $(A_1 \oplus A_2, A_2 \oplus A_3, \dots, A_{n-1} \oplus A_n)$ 替换 。
这里, 表示按位 操作。
设 为在执行了 次操作后得到的、长度为 的序列中的项的值。找出 的最大可能值。
什么是按位 操作?
两个非负整数 和 的按位 ,记作 ,定义如下:
- 在 的二进制表示中,()位上的数字如果是 ,则当且仅当在 或 的 位上是 但不是两者都是 时,它就是 ;否则是 。
例如,(二进制:)。 一般来说, 个非负整数 的按位 定义为 $(\dots ((p_1 \oplus p_2) \oplus p_3) \oplus \dots \oplus p_k)$,并且可以证明这与 的顺序无关。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given a sequence of non-negative integers . Consider performing the following operation times on this sequence to obtain a sequence of length :
- Let be the length of . First, rearrange the elements in in any order you like. Then, replace with a sequence of non-negative integers $(A_1 \oplus A_2, A_2 \oplus A_3, \dots, A_{n-1} \oplus A_n)$.
Here, represents the bitwise operation.
Let be the value of the term contained in the sequence of length obtained after operations. Find the maximum possible value of .
What is the bitwise operation?
The bitwise of two non-negative integers and , denoted as , is defined as follows:
- In the binary representation of , the digit at the () position is if the digit at the position is in or but not both, and otherwise.
For example, (in binary: ).
In general, the bitwise of non-negative integers is defined as $(\dots ((p_1 \oplus p_2) \oplus p_3) \oplus \dots \oplus p_k)$, and it can be proved that this does not depend on the order of .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4
1 2 3 4
Sample Output 1
7
The sequence can be transformed into by the following three operations:
- In the first operation, rearrange to . is replaced with .
- In the second operation, rearrange to . is replaced with .
- In the third operation, rearrange to . is replaced with .
Sample Input 2
13
451745518671773958 43800508384422957 153019271028231120 577708532586013562 133532134450358663 619750463276496276 615201966367277237 943395749975730789 813856754125382728 705285621476908966 912241698686715427 951219919930656543 124032597374298654
Sample Output 2
1152905479775702586