#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define watch(x) cout << (#x) << " : " << x << '\n'
using namespace std;
const int LOG = 30;
void solve() {
int n;
cin >> n;
vector <int> a(n);
for (auto& x : a)
cin >> x;
vector <int> cnt(LOG, 0);
for (auto& x : a)
for (int b = 0; b < LOG; b++)
cnt[b] += (x >> b) & 1;
int ans = 0;
for (int b = 0; b < LOG; b++) {
int pairs = 0;
if (cnt[b] * (n - cnt[b]) & 1)
pairs++;
int msk = (1 << b) - 1;
vector <int> c(n);
for (int i = 0; i < n; i++)
c[i] = a[i] & msk;
sort(all(c));
int r = n;
for (int l = 0; l < n; l++) {
while (r - 1 >= l && c[r - 1] + c[l] >= (1 << b))
r--;
pairs += (n - max(l, r));
pairs &= 1;
}
ans ^= (pairs << b);
}
cout << ans << '\n';
}
int32_t main() {
boost;
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
340 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1545 ms |
12736 KB |
Output is correct |
2 |
Correct |
1450 ms |
11904 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1545 ms |
12736 KB |
Output is correct |
2 |
Correct |
1450 ms |
11904 KB |
Output is correct |
3 |
Execution timed out |
1657 ms |
14900 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
340 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Correct |
208 ms |
2000 KB |
Output is correct |
4 |
Correct |
221 ms |
1980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
340 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Correct |
1545 ms |
12736 KB |
Output is correct |
4 |
Correct |
1450 ms |
11904 KB |
Output is correct |
5 |
Execution timed out |
1657 ms |
14900 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |