#include "bits/stdc++.h"
using namespace std;
//#include "debug.h"
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
long long ans = 0;
for (int bit = 0; bit < 31; bit++) {
long long cnt = 0;
vector<vector<int>> bucket(2);
for (auto& x : a) {
bucket[x >> bit & 1].push_back(x % (1 << bit));
}
std::sort(bucket[0].begin(), bucket[0].end());
std::sort(bucket[1].begin(), bucket[1].end());
for (auto [_, __] : vector<pair<int, int>>{{0, 0}, {1, 1}}) {
auto l = bucket[_];
auto r = bucket[__];
int uk = 0;
for (int i = (int) r.size() - 1; i >= 0; i--) {
while (uk < (int) l.size() && l[uk] + r[i] < (1 << bit)) uk++;
cnt += (int) l.size() - max(uk, i);
}
}
// if (bit == 1) {
// debug(bucket[0], bucket[1], cnt);
// }
for (auto [_, __] : vector<pair<int, int>>{{0, 1}}) {
auto l = bucket[_];
auto r = bucket[__];
int uk = 0;
for (int i = (int) r.size() - 1; i >= 0; i--) {
while (uk < (int) l.size() && l[uk] + r[i] < (1 << bit)) uk++;
cnt += uk;
}
}
if (cnt % 2) {
ans ^= (1 << bit);
}
}
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
336 KB |
Output is correct |
2 |
Correct |
7 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1651 ms |
17148 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1651 ms |
17148 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
336 KB |
Output is correct |
2 |
Correct |
7 ms |
340 KB |
Output is correct |
3 |
Correct |
200 ms |
3040 KB |
Output is correct |
4 |
Correct |
199 ms |
3156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
336 KB |
Output is correct |
2 |
Correct |
7 ms |
340 KB |
Output is correct |
3 |
Execution timed out |
1651 ms |
17148 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |