Problems > Maximum XOR of a Subset

Maximum XOR of a Subset

Difficulty: 2000 4000 ms 128 MB

bitwise linear-algebra

Choose any subset (including empty) of the N values; print the maximum achievable XOR of the chosen elements.

Input: the first line has N; the second line has N non-negative integers.

Output: the maximum subset XOR.

Constraints:

  • 1 ≤ N ≤ 105
  • 0 ≤ ai < 260

Sample Tests

Input 1
3
1 2 3
Output 1
3
Input 2
2
8 8
Output 2
8

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.