이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |