Minimum XOR Sum of Subarrays
Given an array of N integers A, partition it into two non-empty contiguous subarrays. The first subarray will be A[0...i] and the second subarray will be A[i+1...N-1] for some 0 <= i < N-1. Calculate the XOR sum of elements in the first subarray and the XOR sum of elements in the second subarray. Find the minimum possible absolute difference between these two XOR sums over all possible partitions.
Input
The first line contains an integer N. The second line contains N space-separated integers A_1, A_2, ..., A_N.
Output
Print a single integer representing the minimum absolute difference.
Constraints
1 <= N <= 200000 0 <= A_i <= 10^9
Example 1
5 8 1 2 12 7
0
The array can be split after index 3: [8, 1, 2, 12] (XOR sum 7) and [7] (XOR sum 7). The difference is |7-7| = 0.
Example 2
3 1 2 3
0
Split after index 0: [1] (XOR sum 1) and [2, 3] (XOR sum 1). Difference |1-1|=0. Split after index 1: [1, 2] (XOR sum 3) and [3] (XOR sum 3). Difference |3-3|=0.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
5 8 1 2 12 7
3 1 2 3