#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 1001001;
const int MX = 4001;
const int BITS = 60;
ll N;
ll A[MN], freq[MN];
ll ct[BITS];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> N;
for (int i=0; i<N; ++i) {
cin >> A[i];
}
ll ans = 0;
if (N <= MX) {
for (int i=0; i<N; ++i) {
for (int j=i; j<N; ++j) {
ll x = A[i] + A[j];
ans ^= x;
}
}
} else {
for (int i=0; i<N; ++i) ++freq[A[i]];
for (int i=0; i<MX; ++i) {
for (int j=i; j<MX; ++j) {
ll x;
if (i == j) {
x = (freq[i] * (freq[i] + 1)) >> 1;
} else {
x = freq[i] * freq[j];
}
if (x & 1) ans ^= (i+j);
//if (x) cerr << i << ' ' << j << ' ' << x << endl;
}
}
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
364 KB |
Output is correct |
2 |
Correct |
6 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
119 ms |
12772 KB |
Output is correct |
2 |
Correct |
99 ms |
12004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
119 ms |
12772 KB |
Output is correct |
2 |
Correct |
99 ms |
12004 KB |
Output is correct |
3 |
Incorrect |
125 ms |
22884 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
364 KB |
Output is correct |
2 |
Correct |
6 ms |
364 KB |
Output is correct |
3 |
Runtime error |
15 ms |
3112 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
364 KB |
Output is correct |
2 |
Correct |
6 ms |
364 KB |
Output is correct |
3 |
Correct |
119 ms |
12772 KB |
Output is correct |
4 |
Correct |
99 ms |
12004 KB |
Output is correct |
5 |
Incorrect |
125 ms |
22884 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |