#pragma GCC optimize("O3")
#include <unistd.h>
#include <bits/stdc++.h>
using namespace std;
namespace io {
const signed IS=1<<20, OS=1<<18;
char I[IS*32+1],*J=I,O[OS],*K=O;
inline void daer(){if(J>=I+IS-64){char*p=I;do*p++=*J++;while(J!=I+IS);p[read(0,p,I+IS-p)]=0;J=I;}}
template<int N=10,typename T=int>inline T getu(){daer();T x=0;int k=0;do x=x*10+*J-'0';while(*++J>='0'&&++k<N);++J;return x;}
template<int N=10,typename T=int>inline T geti(){daer();bool e=*J=='-';J+=e;return(e?-1:1)*getu<N,T>();}
inline void flush(){write(1,O,K-O);K=O;}
template<int N=10,typename T=int>inline void putu(T n){char s[(N+7)/8*8],*p=s;int k=0;do*p++=n%10+48;while((n/=10)&&++k<N);do*K++=*--p;while(p!=s);*K++=10;if(K>=O+OS-64)flush();}
template<int N=10,typename T=int>inline void puti(T n){if(n<0)*K++='-',n=-n;putu<N,T>(n);}
struct f{f(){I[read(0,I,IS)]=0;}~f(){flush();}}flu;
};
using namespace io;
typedef long long ll;
const int MAX_N = 1000000;
const int MAX_LOGV = 30;
int arr[MAX_N];
int remain[MAX_N];
ll digitNum[MAX_LOGV];
void run(){
int N = getu<7>();
memset(digitNum,0,sizeof(digitNum));
for(int i=0;i<N;i++){
arr[i] = getu<9>();
}
for(int digit=0;digit<MAX_LOGV;digit++){
for(int i=0;i<N;i++){
remain[i] = arr[i]&((1<<(digit+1))-1);
}
sort(remain,remain+N);
int lo,hi;
for(int i=0;i<N;i++){
lo = i;
while(lo<N and !((remain[i]+remain[lo])&(1<<digit))) lo++;
hi = lo;
while(hi<N and ((remain[i]+remain[hi])&(1<<digit))) hi++;
digitNum[digit]+=hi-lo;
}
}
int ret = 0;
for(int digit=0;digit<MAX_LOGV;digit++){
ret+= (digitNum[digit]&1) ? (1<<digit) : 0;
}
putu(ret);
}
int main(){
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
//cout.tie(NULL);
run();
return 0;
}
Compilation message
xorsum.cpp: In function 'void io::flush()':
xorsum.cpp:12:27: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | inline void flush(){write(1,O,K-O);K=O;}
| ~~~~~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
130 ms |
404 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1655 ms |
13700 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1655 ms |
13700 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
130 ms |
404 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
130 ms |
404 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |