#include <bits/stdc++.h>
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "LINE(" << __LINE__ << "): " << #x << " is " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;
const int INF = 1e9 + 7, N = 1e6 + 1;
signed main()
{
ios::sync_with_stdio(0), cin.tie(0);
mt19937 rng(time(0));
int n;
cin >> n;
//n = 10;
vi a(n);
for(int i = 0; i < n; i++) {
cin >> a[i];
//a[i] = rng() % 100;
}
/*int myans = 0;
for(int i = 0; i < n; i++)
for(int j = i; j < n; j++)
myans ^= a[i] + a[j];
debug(myans);
*/
int ans = 0;
for(int bit = 0; bit < 30; bit++) {
ll cnt = 0;
vi aux(n);
for(int i = 0; i < n; i++) {
aux[i] = a[i] & ((1 << (bit + 1)) - 1);
if((a[i] * 2) >> bit & 1) cnt++;
}
sort(ALL(aux));
for(int i = 0; i < n; i++) {
auto go = [&] (ll lb, ll rb) {
lb -= aux[i], rb -= aux[i];
cnt += upper_bound(ALL(aux), rb) - lower_bound(ALL(aux), lb);
};
go(1 << bit, (1 << (bit + 1)) - 1);
go(3 << bit, (2LL << (bit + 1)) - 1);
}
//debug(cnt);
assert(cnt % 2 == 0);
cnt /= 2;
if(cnt & 1) ans |= 1 << bit;
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
332 KB |
Output is correct |
2 |
Correct |
20 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1663 ms |
8208 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1663 ms |
8208 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
332 KB |
Output is correct |
2 |
Correct |
20 ms |
332 KB |
Output is correct |
3 |
Correct |
593 ms |
1220 KB |
Output is correct |
4 |
Correct |
616 ms |
1100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
332 KB |
Output is correct |
2 |
Correct |
20 ms |
332 KB |
Output is correct |
3 |
Execution timed out |
1663 ms |
8208 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |