This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int arr[maxn], n;
int A[maxn], B[maxn], p1, p2;
int check() {
int ret = 0;
for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j++)
ret ^= arr[i] + arr[j];
return ret;
}
void solve() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> arr[i];
int ans = 0;
for (int i = 0; i < 30; i++) {
int R = (1<<i) - 1;
p1 = p2 = 0;
for (int j = 1; j <= n; j++)
if ((arr[j]>>i)&1) B[++p2] = arr[j];
else A[++p1] = arr[j];
int ptr = p1 + 1;
for (int j = 1; j <= p1; j++) {
while (ptr > j && (A[j]&R) + (A[ptr-1]&R) >= (1<<i)) ptr--;
if (ptr < j) ptr = j;
if ((p1-ptr+1)&1) ans ^= (1<<i);
}
ptr = p2 + 1;
for (int j = 1; j <= p2; j++) {
while (ptr > j && (B[j]&R) + (B[ptr-1]&R) >= (1<<i)) ptr--;
if (ptr < j) ptr = j;
if ((p2-ptr+1)&1) ans ^= (1<<i);
}
ptr = p2;
for (int j = 1; j <= p1; j++) {
while (ptr && (A[j]&R)+(B[ptr]&R) >= (1<<i)) ptr--;
if (ptr&1) ans ^= (1<<i);
}
for (int j = 1; j <= p1; j++) arr[j] = A[j];
for (int j = 1; j <= p2; j++) arr[p1 + j] = B[j];
}
cout << ans << '\n';
}
signed main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
solve();
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... |