#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e6+5;
int a[MAXN],b[MAXN];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,ans=0;
cin >> n;
for(int i=1;i<=n;i++){
cin >> a[i];
}
for(int i=0;i<29;i++){
for(int j=1;j<=n;j++)b[j]=a[j]&((1<<(i+1))-1);
sort(b+1,b+n+1);
// for(int j=1;j<=n;j++)cout << b[j] << " ";
// cout << '\n';
int ret=0;
for(int j=1;j<=n;j++){
int ki=j,ka=n,res=-1;
while(ki<=ka){
int mid=(ki+ka)/2;
if(b[j]+b[mid]>=(1<<i)){
res=mid;
ka=mid-1;
}
else ki=mid+1;
}
int awalkel2,awalkel3,awalkel4;
if(res!=-1){
if(b[j]+b[res]<(1<<(i+1))){
awalkel2=res;
ki=res+1;ka=n;res=-1;
while(ki<=ka){
int mid=(ki+ka)/2;
if(b[j]+b[mid]>=(1<<(i+1))){
res=mid;
ka=mid-1;
}
else ki=mid+1;
}
if(res!=-1){
if(b[j]+b[res]<=(3*(1<<i))-1){
awalkel3=res;
ki=res+1;ka=n;res=-1;
while(ki<=ka){
int mid=(ki+ka)/2;
if(b[j]+b[mid]>=3*(1<<i)){
res=mid;
ka=mid-1;
}
else ki=mid+1;
}
if(res!=-1){
awalkel4=res;
if((awalkel3-awalkel2+n-awalkel4+1)&1)ret^=(1<<i);
}
else{
if((awalkel3-awalkel2)&1)ret^=(1<<i);
}
}
else{
awalkel4=res;
if((n+1-awalkel2)&1)ret^=(1<<i);
}
}
else{
if((n+1-awalkel2)&1)ret^=(1<<i);
}
}
else if(b[j]+b[res]<=(3*(1<<i))-1){
awalkel3=res;
ki=res+1;ka=n;res=-1;
while(ki<=ka){
int mid=(ki+ka)/2;
if(b[j]+b[mid]>=3*(1<<i)){
res=mid;
ka=mid-1;
}
else ki=mid+1;
}
if(res!=-1){
awalkel4=res;
if((n-awalkel4+1)&1)ret^=(1<<i);
}
}
else{
awalkel4=res;
if((n-awalkel4+1)&1)ret^=(1<<i);
}
}
}
ans+=ret;
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
364 KB |
Output is correct |
2 |
Correct |
14 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1697 ms |
12780 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1697 ms |
12780 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
364 KB |
Output is correct |
2 |
Correct |
14 ms |
364 KB |
Output is correct |
3 |
Correct |
398 ms |
2028 KB |
Output is correct |
4 |
Correct |
403 ms |
2156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
364 KB |
Output is correct |
2 |
Correct |
14 ms |
364 KB |
Output is correct |
3 |
Execution timed out |
1697 ms |
12780 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |