#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<=40;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 low=0,high=v.size();
while(low!=high){
int mid = (low+high)/2;
if(i+v[mid]>=(1LL<<j)){
high = mid;
}
else{
low = mid+1;
}
}
int low2=0,high2=v.size();
while(low2!=high2){
int mid2 = (low2+high2)/2;
if(i+v[mid2]>=(1LL<<(j+1LL))){
high2 = mid2;
}
else{
low2 = mid2+1;
}
}
cnt += low2-low;
}
curr += cnt/2LL;
vector<int> v2,v3;
for(int i:va){
if(i&(1LL<<j)){
v3.push_back(i);
curr += (n+1);
}
else{
v2.push_back(i);
}
}
va.clear();
for(int i:v2){
va.push_back(i);
}
for(int i:v3){
va.push_back(i);
}
if(curr%2){
ans += (1LL<<j);
}
}
cout << ans << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
512 KB |
Output is correct |
2 |
Correct |
9 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1666 ms |
40948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1666 ms |
40948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
512 KB |
Output is correct |
2 |
Correct |
9 ms |
596 KB |
Output is correct |
3 |
Correct |
315 ms |
4532 KB |
Output is correct |
4 |
Correct |
290 ms |
4512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
512 KB |
Output is correct |
2 |
Correct |
9 ms |
596 KB |
Output is correct |
3 |
Execution timed out |
1666 ms |
40948 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |