#include <bits/stdc++.h>
#define GOOD_LUCK ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;
constexpr int MAX = 2e+5 + 1, INF = 2e+9, MOD = 1e+9 + 7, K = 28;
void mysort(vector <int> &v) {
int n = v.size();
vector <int> o = v;
int ma=*max_element(all(v));
int b = sqrt(ma * 2) + 10;
vector <int> id;
for (int i = 0; i < n; i++) id.pb(i);
for (int i = 0; i < 2; i++) {
vector <vector <int>> c(b);
for (int &j : id) {
int x = v[j] % b;
v[j] /= b;
c[x].pb(j);
}
id.clear();
for (int j = 0; j < b; j++) {
for (int &z : c[j]) id.pb(z);
}
}
for (int i=0; i < n; i++) v[i] = o[id[i]];
}
void _() {
int n;
cin >> n;
vector <int> v(n);
for (int &i : v) cin >> i;
int res=0;
for (int i = K; i >= 0; i--) {
vector <int> x = v;
int m = (1LL << (i + 1));
for (int &j : x) j %= m;
mysort(x);
ll c=0;
while (!x.empty()) {
int k = x.back();
int mn = (1LL << i);
int mx = (1LL << (i + 1)) - 1;
mn -= k, mx -= k;
if (mn <= mx) c += upper_bound(all(x), mx) - lower_bound(all(x), mn);
mn = (1LL << i) * 3;
mx = (1LL << (i + 2)) - 1;
mn -= k, mx -= k;
if (mn <= mx) c += upper_bound(all(x), mx) - lower_bound(all(x), mn);
x.pop_back();
}
res += (1LL << i) * (c % 2);
}
cout << res;
}
signed main() {
GOOD_LUCK
int tests=1;
// cin >> tests;
for (int i=1; i <= tests; i++) {
_();
cout << endl;
}
return 0;
}
/*
0011
0110
0110
1001
001
011
110
110
100 -> min
111 -> max
*/
| # | 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... |