#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int res = 0, k, v;
for (int i = 30; i >= 0; --i) {
sort(a.rbegin(), a.rend());
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... |