#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef pair < int , int > pp;
typedef vector < int > vi;
const int mod = 1e9 + 7;
const int N = 1e6 + 6;
int T[N],A[N],one[N],o,zer[N],z,n,i,j,x,t,ans;
int main (){
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d",&A[i]);
}
for(j=0;j<31;j++){
z = o = 0;
for(i=1;i<=n;i++){
x = A[i];
if(x & (1<<j)){
one[++o] = T[i];
}
else{
zer[++z] = T[i];
}
}
sort(zer+1 , zer+z+1);
sort(one+1 , one+o+1);
t = 0;
for(i=1;i<=n;i++){
x = A[i];
if(x & (1<<j)){
t += o+1 - (int)(lower_bound(one+1 , one+o+1 , (1<<j)-T[i]) - one);
t += (int)(lower_bound(zer+1 , zer+z+1 , (1<<j)-T[i]) - zer-1);
}
else{
t += z+1 - (int)(lower_bound(zer+1 , zer+z+1 , (1<<j)-T[i]) - zer);
t += (int)(lower_bound(one+1 , one+o+1 , (1<<j)-T[i]) - one-1);
}
t = t&1;
}
if(t)
ans += 1 << j;
for(i=1;i<=n;i++)
T[i] += A[i] & (1 << j);
}
printf("%d",ans);
return 0;
}
Compilation message
xorsum.cpp: In function 'int main()':
xorsum.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
~~~~~^~~~~~~~~
xorsum.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&A[i]);
~~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
33 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1649 ms |
13500 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1649 ms |
13500 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
33 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
33 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |