#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int n,ans;
int arr[1000005];
vector<int> va;
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i=1;i<=n;i++){
cin >> arr[i];
va.push_back(arr[i]);
}
for(int j=0;j<=31;j++){
int curr=0;
vector<int> v;
for(int i:va){
v.push_back(i%(1LL<<j));
}
int cnt=0;
for(int i:v){
if(i+i>=(1LL<<j) and i+i<(1LL<<(j+1LL))){
cnt++;
}
}
int pa=n,pb=n;
for(int i:v){
while(pa!=0 and i+v[pa-1]>=(1LL<<j)){
pa--;
}
while(pb!=0 and i+v[pb-1]>=(1LL<<(j+1LL))){
pb--;
}
cnt += pb-pa;
}
curr += cnt/2LL;
vector<int> va2;
for(int i:va){
if(i&(1LL<<j)){
curr += (n+1);
}
else{
va2.push_back(i);
}
}
for(int i:va){
if(i&(1LL<<j)){
va2.push_back(i);
}
}
va = va2;
if(curr%2){
ans += (1LL<<j);
}
}
cout << ans << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
468 KB |
Output is correct |
2 |
Correct |
4 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
759 ms |
39884 KB |
Output is correct |
2 |
Correct |
713 ms |
42312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
759 ms |
39884 KB |
Output is correct |
2 |
Correct |
713 ms |
42312 KB |
Output is correct |
3 |
Correct |
917 ms |
46676 KB |
Output is correct |
4 |
Correct |
849 ms |
45312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
468 KB |
Output is correct |
2 |
Correct |
4 ms |
468 KB |
Output is correct |
3 |
Correct |
101 ms |
4584 KB |
Output is correct |
4 |
Correct |
96 ms |
4540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
468 KB |
Output is correct |
2 |
Correct |
4 ms |
468 KB |
Output is correct |
3 |
Correct |
759 ms |
39884 KB |
Output is correct |
4 |
Correct |
713 ms |
42312 KB |
Output is correct |
5 |
Correct |
917 ms |
46676 KB |
Output is correct |
6 |
Correct |
849 ms |
45312 KB |
Output is correct |
7 |
Correct |
101 ms |
4584 KB |
Output is correct |
8 |
Correct |
96 ms |
4540 KB |
Output is correct |
9 |
Correct |
1061 ms |
49380 KB |
Output is correct |
10 |
Correct |
1020 ms |
49220 KB |
Output is correct |
11 |
Correct |
1044 ms |
49348 KB |
Output is correct |