#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define epb emplace_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define inf 1e9+1
#define linf 1e18+1
using namespace std;
main(){
int n;cin>>n;
ios_base::sync_with_stdio(false);cin.tie(0);
int a[n+1];
int mx=0;
for(int i=1;i<=n;i++){
cin>>a[i];
mx=max(mx,a[i]);
}
int ans=0;
int vec[n];
if(mx<=1e6){
int pref[8*mx+1];
int xx=log2(mx)+2;
for(int bt=1;bt<=xx;bt++){
for(int i=0;i<n;i++){
vec[i]=a[i+1]%(1<<bt);
}
for(int j=0;j<=8*mx;j++)pref[j]=0;
for(int i=0;i<n;i++){
pref[vec[i]]++;
}
for(int i=1;i<=8*mx;i++)pref[i]+=pref[i-1];
int cnt=0;
int l=(1<<(bt-1));int r=2*l;
for(int i=0;i<n;i++){
int to=vec[i];
if(2*to>=l&&2*to<r)cnt++;
if(2*to>=r+l)cnt++;
cnt+=pref[r-to-1];
if(l>to)cnt-=pref[l-to-1];
cnt+=pref[8*mx];
if(r+l>to)cnt-=pref[r+l-to-1];
}
cnt>>=1;
if(cnt&1)ans+=(1<<(bt-1));
}
cout<<ans<<"\n";
return 0;
}
mx=log2(mx);
for(int bt=1;bt<=mx+2;bt++){
for(int i=0;i<n;i++){
vec[i]=a[i+1]%(1<<bt);
}
sort(vec,vec+n);
int cnt=0;
int l=(1<<(bt-1)),r=2*l;
for(int i=0;i<n;i++){
int to=vec[i];
if(2*to>=l&&2*to<r)cnt++;
if(2*to>=r+l)cnt++;
cnt+=lower_bound(vec,vec+n,r-to)-lower_bound(vec,vec+n,l-to);
cnt+=vec+n-lower_bound(vec,vec+n,r+l-to);
}
cnt>>=1;
if(cnt&1)ans+=(1<<(bt-1));
}
cout<<ans;
return 0;
}
Compilation message
xorsum.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
15 | main(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
344 KB |
Output is correct |
2 |
Correct |
15 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
244 ms |
8244 KB |
Output is correct |
2 |
Correct |
239 ms |
7712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
244 ms |
8244 KB |
Output is correct |
2 |
Correct |
239 ms |
7712 KB |
Output is correct |
3 |
Correct |
926 ms |
39428 KB |
Output is correct |
4 |
Correct |
879 ms |
45652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
344 KB |
Output is correct |
2 |
Correct |
15 ms |
340 KB |
Output is correct |
3 |
Correct |
442 ms |
1080 KB |
Output is correct |
4 |
Correct |
435 ms |
1076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
344 KB |
Output is correct |
2 |
Correct |
15 ms |
340 KB |
Output is correct |
3 |
Correct |
244 ms |
8244 KB |
Output is correct |
4 |
Correct |
239 ms |
7712 KB |
Output is correct |
5 |
Correct |
926 ms |
39428 KB |
Output is correct |
6 |
Correct |
879 ms |
45652 KB |
Output is correct |
7 |
Correct |
442 ms |
1080 KB |
Output is correct |
8 |
Correct |
435 ms |
1076 KB |
Output is correct |
9 |
Execution timed out |
1656 ms |
17392 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |