#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
int n, res;
int ar[1000006];
int tar[1000006];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> ar[i];
}
for (int j = 0; j < 31; j++) {
for (int i = 0; i < n; i++) {
tar[i] = ar[i] % (1 << (j + 1));
}
sort(tar, tar + n);
int sum = 0;
for (int i = 0; i < n; i++) {
int p1, p2, p3;
p1 = p2 = p3 = i - 1;
int l = i, r = n - 1;
while (l <= r) {
int m = (l + r) / 2;
if (tar[i] + tar[m] < (1 << j)) {
p1 = m;
l = m + 1;
} else {
r = m - 1;
}
}
l = i, r = n - 1;
while (l <= r) {
int m = (l + r) / 2;
if (tar[i] + tar[m] < (2 * (1 << j))) {
p2 = m;
l = m + 1;
} else {
r = m - 1;
}
}
l = i, r = n - 1;
while (l <= r) {
int m = (l + r) / 2;
if (tar[i] + tar[m] < (3 * (1 << j))) {
p3 = m;
l = m + 1;
} else {
r = m - 1;
}
}
sum += p2 - p1 + n - p3;
}
if (sum & 1) res += (1 << j);
}
cout << res << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
332 KB |
Output is correct |
2 |
Correct |
16 ms |
440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1643 ms |
20444 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1643 ms |
20444 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
332 KB |
Output is correct |
2 |
Correct |
16 ms |
440 KB |
Output is correct |
3 |
Correct |
487 ms |
2820 KB |
Output is correct |
4 |
Correct |
481 ms |
2816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
332 KB |
Output is correct |
2 |
Correct |
16 ms |
440 KB |
Output is correct |
3 |
Execution timed out |
1643 ms |
20444 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |