# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
362478 | 2021-02-03T10:42:58 Z | keta_tsimakuridze | XOR Sum (info1cup17_xorsum) | C++14 | 1600 ms | 49852 KB |
#include<bits/stdc++.h> #define int long long #define f first #define s second using namespace std; const int N=1e6+5; int a[N],ind[N],s[N],n,cnt,c[2],ans,cur,pos[N]; vector< int > v[2]; void Sort(int i){ v[0].clear(); v[1].clear(); for(int k=1;k<=n;k++){ v[(((1<<i)&a[pos[k]])>0)].push_back(pos[k]); } cur=0; for(int j=0;j<=1;j++){ for(int k=0;k<v[j].size();k++){ cur++; pos[cur]=v[j][k]; ind[v[j][k]]=cur; } } } main(){ cin>>n; for(int k=1;k<=n;k++){ cin>>a[k]; pos[k]=k; ind[k]=k; cnt+=c[(a[k]&1)^1]; c[a[k]&1]++; s[k]=a[k]&1; } if(cnt%2) ans=1; Sort(0); for(int i=1;i<=30;i++){ Sort(i); for(int k=1;k<=n;k++) s[k]+=a[k]&(1<<i); cnt=0; int l=n,r=n,l1=n,r1=n; for(int k=1;k<=n;k++){ while(r && s[pos[r]] + s[pos[k]] >= (1ll<<(i+1)) ) r--; while(l && s[pos[l]] + s[pos[k]] >= (1ll<<i) ) l--; cnt += r-l; while( l1&&s[pos[l1]] + s[pos[k]] >=((1ll<<(i+1))+(1ll<<i)) ) l1--; cnt+=n-l1; } int c1=0; for(int k=1;k<=n;k++){ if((2*a[k])&(1ll<<i)) c1++; } if((c1+(cnt-c1)/2)%2==1) ans+=1ll<<i; } cout<<ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 620 KB | Output is correct |
2 | Correct | 7 ms | 620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1696 ms | 49852 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1696 ms | 49852 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 620 KB | Output is correct |
2 | Correct | 7 ms | 620 KB | Output is correct |
3 | Correct | 188 ms | 5644 KB | Output is correct |
4 | Correct | 187 ms | 5600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 620 KB | Output is correct |
2 | Correct | 7 ms | 620 KB | Output is correct |
3 | Execution timed out | 1696 ms | 49852 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |