#include<bits/stdc++.h>
#define int 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;
int dp[1001][101];
main(){
int n;cin>>n;
int a[n+1];
int mx=0;
for(int i=1;i<=n;i++){
cin>>a[i];
mx=max(mx,a[i]);
}
mx=log2(mx);
int ans=0;
for(int bt=1;bt<=mx+2;bt++){
vector<int>vec;
for(int i=1;i<=n;i++){
vec.pb(a[i]%(1<<bt));
}
sort(vec.begin(),vec.end());
int cnt=0;
int l=(1<<(bt-1)),r=2*l;
for(int to:vec){
if(2*to>=l&&2*to<r)cnt++;
if(2*to>=r+l)cnt++;
cnt+=lower_bound(vec.begin(),vec.end(),r-to)-lower_bound(vec.begin(),vec.end(),l-to);
cnt+=vec.end()-lower_bound(vec.begin(),vec.end(),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(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
332 KB |
Output is correct |
2 |
Correct |
16 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1519 ms |
24240 KB |
Output is correct |
2 |
Correct |
1407 ms |
27548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1519 ms |
24240 KB |
Output is correct |
2 |
Correct |
1407 ms |
27548 KB |
Output is correct |
3 |
Execution timed out |
1636 ms |
31144 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
332 KB |
Output is correct |
2 |
Correct |
16 ms |
332 KB |
Output is correct |
3 |
Correct |
501 ms |
3140 KB |
Output is correct |
4 |
Correct |
443 ms |
3000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
332 KB |
Output is correct |
2 |
Correct |
16 ms |
332 KB |
Output is correct |
3 |
Correct |
1519 ms |
24240 KB |
Output is correct |
4 |
Correct |
1407 ms |
27548 KB |
Output is correct |
5 |
Execution timed out |
1636 ms |
31144 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |