AmazonOA #218
Get Minimum Moves to Zero
估计中等可在线判题
The array has even length. One operation chooses any 0≤L≤R<n, computes the XOR x of all elements in the range before the operation, then sets every element in the range to x simultaneously. Find the minimum number of operations to make every element zero.
输入格式
The first line contains an even n; the second line contains the array. The original text only specifies that n is even; this site uses 2≤n≤200000; 0≤element<2^20.
输出格式
Output a single integer, the answer.
样例 1
输入:
2
0 0
输出:
0
样例 2
输入:
2
3 3
输出:
1
样例 3
输入:
2
1 2
输出:
2
样例说明
The answers are 0, 1 and 2. Third example: 1,2→3,3→0,0.