#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> a(n), b(n);
for(int i = 0; i < n; ++ i){
cin >> b[i];
}
int res = 0, k, v;
for(int i = 0, n0 = 0, n1 = 0; i <= 30; ++ i){
n0 = n1 = 0;
for(int j = 0; j < n; ++ j)
if((b[j]>>i)&1)
b[n1 ++] = b[j];
else
a[n0 ++] = b[j];
for(int j = n1, t = 0; j < n; ++ j, ++ t)
b[j] = a[t];
for(int j = 0; j < n; ++ j)
a[j] = b[j] & ((1<<(i+1)) - 1);
k = 0;
for(int j = 0, p = n - 1, q = n-1, w = n - 1; j < n; ++ j){
if((a[j]>>i) & 1){
v = (1<<(i+1))-a[j] - 1;
p = max(p, j);
while(p >= j && a[p] <= v) -- p;
k += (n - 1 - p) & 1;
v = (3<<i) - a[j];
q = max(q, j);
while(q >= j && a[q] < v) -- q;
k += (q - j + 1) & 1;
a[j] ^= 1<<i;
}
else{
v = (1<<i) - a[j];
w = max(w, j);
while(w >= j && a[w] < v) -- w;
k += (w - j + 1) & 1;
}
}
if(k & 1) res |= 1<<i;
}
cout << res << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |