#include <bits/stdc++.h>
using namespace std;
const int M=29;
int n,a[1000004],b[1000004];
int c[39],ans;
void work(int x,int y,int &k,int &K){
int l=-1,r=-1;
for(int o=n-1;o>=0;o--){
// cout<<b[o]<<endl;
while(l+1<n&&b[l+1]+b[o]<x) l++;
while(r+1<n&&b[r+1]+b[o]<=y) r++;
if(o>l&&o<=r) K++;
if(l<=r)
k+=(r-l);
// cout<<l<<" "<<r<<" "<<x<<" "<<y<<" "<<b[o]<<" "<<b[r]<<endl;
}
}
int main(){
ios::sync_with_stdio(false);
for(int i=1;i<=M;i++){
c[i]=(1<<(i+1))-1;
}
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=1;i<=M;i++){
for(int j=0;j<n;j++){
b[j]=c[i]&a[j];
}
sort(b,b+n);
int b1=(1<<(i));
int b2=((1<<(i+1))-1);
int B1=b1+(1<<(i+1));
int B2=((1<<(i+2))-2);
int k=0,K=0;
work(b1,b2,k,K);
work(B1,B2,k,K);
k-=K;
k/=2;
k+=K;
// cout<<k<<endl;
if(k&1){
ans|=(1<<(i));
}
}
int k=0;
for(int i=0;i<n;i++){
if(a[i]&1) k++;
}
if((k*(n-k))&1){
ans++;
}
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
376 KB |
Output is correct |
2 |
Correct |
12 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1655 ms |
8184 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1655 ms |
8184 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
376 KB |
Output is correct |
2 |
Correct |
12 ms |
376 KB |
Output is correct |
3 |
Correct |
272 ms |
2116 KB |
Output is correct |
4 |
Correct |
274 ms |
2168 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
376 KB |
Output is correct |
2 |
Correct |
12 ms |
376 KB |
Output is correct |
3 |
Execution timed out |
1655 ms |
8184 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |