This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
int n;cin>>n;
vector<ll> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
vector<int> co(30);
vector<int> v(n),id(n),vv(n),idd(n);
for(int i=0;i<n;i++){
id[i]=i;
}
vector<int> s(n+1);
for(int k=0;k<30;k++){
int j=n-1;
for(int i=1;i<=n;i++){
s[i]=s[i-1]+((a[id[i-1]]>>k)&1);
}
int sum=n-s[n];
int id0=0,id1=0;
for(int i=0;i<n;i++){
while(j>=0&&(1<<k)-v[i]<=v[j])--j;
if((a[id[i]]>>k)&1){
if(i>j)co[k]+=s[i+1]-s[j+1];
co[k]+=min(i+1,j+1)-s[min(i+1,j+1)];
vv[sum+id1]=(1<<k)+v[i];
idd[sum+id1]=id[i];
id1++;
}else{
if(i>j)co[k]+=(i-j)-(s[i+1]-s[j+1]);
co[k]+=s[min(i+1,j+1)];
vv[id0]=v[i];
idd[id0]=id[i];
id0++;
}
co[k]&=1;
}
swap(v,vv);
swap(id,idd);
}
int ans=0;
for(int k=0;k<30;k++){
if(co[k]){
ans^=(1<<k);
}
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |