#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
//#define int long long int
using namespace std;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, ans = 0;
cin >> n;
vector<int> arr(n);
vector<ii> A;
for(int i = 0; i < n; i++) cin >> arr[i], A.pb({0, i});
for(int d = 0; d <= 30; d++){
long long int w = (1ll << d);
vector<ii> t0, t1;
for(auto p : A){
if(arr[p.second] & w) t1.pb({arr[p.second] % (w * 2), p.second});
else t0.pb({arr[p.second] % (w * 2), p.second});
}
swap(A, t0);
for(auto p : t1) A.pb(p);
int p1 = n - 1, p2 = n - 1, p3 = n - 1, cnt = 0;
for(auto p : A){
while(p1 >= 0 && A[p1].first + p.first >= w) p1--;
while(p2 >= 0 && A[p2].first + p.first >= 2ll * w) p2--;
while(p3 >= 0 && A[p3].first + p.first >= 3ll * w) p3--;
cnt += n - 1 - p3 + p2 - p1;
}
for(auto p : A){
if((p.first * 2) & w) cnt++;
}
assert(cnt % 2 == 0);
cnt /= 2;
if(cnt % 2) ans |= w;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
798 ms |
38304 KB |
Output is correct |
2 |
Correct |
749 ms |
38636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
798 ms |
38304 KB |
Output is correct |
2 |
Correct |
749 ms |
38636 KB |
Output is correct |
3 |
Correct |
951 ms |
42144 KB |
Output is correct |
4 |
Correct |
886 ms |
39140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
3 |
Correct |
109 ms |
5252 KB |
Output is correct |
4 |
Correct |
111 ms |
5396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
3 |
Correct |
798 ms |
38304 KB |
Output is correct |
4 |
Correct |
749 ms |
38636 KB |
Output is correct |
5 |
Correct |
951 ms |
42144 KB |
Output is correct |
6 |
Correct |
886 ms |
39140 KB |
Output is correct |
7 |
Correct |
109 ms |
5252 KB |
Output is correct |
8 |
Correct |
111 ms |
5396 KB |
Output is correct |
9 |
Correct |
1239 ms |
40816 KB |
Output is correct |
10 |
Correct |
1214 ms |
46692 KB |
Output is correct |
11 |
Correct |
1163 ms |
46632 KB |
Output is correct |