#include<iostream>
#include<cassert>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<set>
#include<queue>
#include<map>
using namespace std;
const int N = (int)1e6 + 7;
const int M = (int)1e6 + 7;
const int inf = (int)1e9 + 7;
const int MOD = (int)998244353;
const long long INF = (long long)1e18 + 7;
int mult(int x, int y) {
return 1ll*x*y%MOD;
}
int sum(int x, int y) {
x += y;
if(x >= MOD) {
x -= MOD;
}
return x;
}
int sub(int x, int y) {
x -= y;
if(x < 0) {
x += MOD;
}
return x;
}
int n, a[N], b[N];
long long f(int l, int r) {
long long cur = 0;
sort(a+1, a+1+n);
int j = 0, k = 0;
for(int i = n; i >= 1; --i) {
while(k<n && a[k+1] <= r-a[i]) {
k++;
}
while(j<n && a[j+1] < l-a[i]) {
j++;
}
cur += min(i, k)-min(i, j);
}
return cur;
}
int main() {
ios_base::sync_with_stdio(NULL);
cin.tie(0);
cin >> n;
for(int i = 1; i <= n; ++i) {
cin >> a[i];
}
int ans = 0;
for(int j = 29; j >= 0; --j) {
long long cur = f((1 << j), (1 << (j+1))-1) + f((1 << j) + (1 << (j+1)), (1 << (j+2))-1);
for(int i = 1; i <= n; ++i) {
if(a[i] >> j & 1) {
a[i] ^= (1 << j);
}
}
if(cur&1) {
ans |= (1 << j);
}
}
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2396 KB |
Output is correct |
2 |
Correct |
8 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1004 ms |
6032 KB |
Output is correct |
2 |
Correct |
915 ms |
10320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1004 ms |
6032 KB |
Output is correct |
2 |
Correct |
915 ms |
10320 KB |
Output is correct |
3 |
Correct |
1487 ms |
12776 KB |
Output is correct |
4 |
Correct |
1409 ms |
12396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2396 KB |
Output is correct |
2 |
Correct |
8 ms |
2396 KB |
Output is correct |
3 |
Correct |
191 ms |
4444 KB |
Output is correct |
4 |
Correct |
191 ms |
5468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2396 KB |
Output is correct |
2 |
Correct |
8 ms |
2396 KB |
Output is correct |
3 |
Correct |
1004 ms |
6032 KB |
Output is correct |
4 |
Correct |
915 ms |
10320 KB |
Output is correct |
5 |
Correct |
1487 ms |
12776 KB |
Output is correct |
6 |
Correct |
1409 ms |
12396 KB |
Output is correct |
7 |
Correct |
191 ms |
4444 KB |
Output is correct |
8 |
Correct |
191 ms |
5468 KB |
Output is correct |
9 |
Execution timed out |
1618 ms |
15184 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |