#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
using pii = pair<int,int>;
#define fs first
#define sc second
int n, a[1888888], B = 30;
vector<pii> v;
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
// if (n > 100000) B = 12;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int ans = 0;
for (int b = 0; b < B; b++) {
int z = (1<<(b+1))-1;
if (b > 0) {
vector<pii> v2[2];
for (int i = 0; i < n; i++) v2[(a[v[i].sc]>>b)&1].emplace_back(z&a[v[i].sc], v[i].sc);
v.clear();
for (auto x : v2[0]) v.push_back(x);
for (auto x : v2[1]) v.push_back(x);
}
else {
for (int i = 1; i <= n; i++) v.emplace_back(z&a[i], i);
sort(v.begin(), v.end());
}
// for (auto x : v) cout << x.fs << ' ';
// cout << '\n';
long long cnt = 0;
int th1 = (1<<b), th2 = (1<<(b+1)), th3 = th1+th2;
for (int i = 0, j=n, j2=n, j3=n; i < n; i++) {
while (j3 > 0 and v[i].fs+v[j3-1].fs >= th3) j3--;
if (j2 > j3) j2 = j3;
while (j2 > 0 and v[i].fs+v[j2-1].fs >= th2) j2--;
if (j > j2) j = j2;
while (j > 0 and v[i].fs+v[j-1].fs >= th1) j--;
int a1 = n - j, a2 = n - j2, a3 = n - j3;
cnt += (a1-a2);
cnt += (a3);
}
for (int i = 1; i <= n; i++) if ((a[i]+a[i])&(1<<b)) cnt++;
cnt /= 2;
if (cnt & 1) ans += (1<<b);
}
cout << ans << '\n';
}
# | 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... |