Submission #2414552
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
const int MAX=200000,MQ=28;
int a[MAX],b[MAX],fin,n;
int mask=0;
bool cmp(int &x,int &y){
return (x&mask)<(y&mask);
}
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%d",&a[i]);
for(int i=0;i<n;i++) scanf("%d",&b[i]);
if(n%2) for(int i=0;i<n;i++) fin^=a[i],fin^=b[i];
for(int i=0;i<=MQ;i++){
int val=0;
mask^=(1<<i);
sort(a,a+n,cmp);
sort(b,b+n,cmp);
for(int j=0,k=n;j<n;j++){
for(;(b[k-1]&mask)+(a[j]&mask)>mask&&k>=1;k--);
val+=n-k;
}
if(val%2) fin^=mask+1;
//printf("%d %d\n",mask+1,val);
}
printf("%d\n",fin);
}
Submission Info
Submission Time |
|
Task |
D - Two Sequences |
User |
x0000ai |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
716 Byte |
Status |
AC |
Exec Time |
969 ms |
Memory |
1792 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:10:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:11:43: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for(int i=0;i<n;i++) scanf("%d",&a[i]);
^
./Main.cpp:12:43: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for(int i=0;i<n;i++) scanf("%d",&b[i]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
500 / 500 |
Status |
|
|
Set Name |
Test Cases |
Sample |
example_0, example_1, example_2, example_3 |
All |
N100000_0, N100000_1, N150000_0, N150000_1, N200000_0, N200000_1, N200000_ex_0, N200000_ex_1, example_0, example_1, example_2, example_3, rand_0, rand_1, smallrand_0, smallrand_1 |
Case Name |
Status |
Exec Time |
Memory |
N100000_0 |
AC |
467 ms |
1152 KB |
N100000_1 |
AC |
469 ms |
1024 KB |
N150000_0 |
AC |
710 ms |
1408 KB |
N150000_1 |
AC |
705 ms |
1408 KB |
N200000_0 |
AC |
969 ms |
1792 KB |
N200000_1 |
AC |
960 ms |
1792 KB |
N200000_ex_0 |
AC |
911 ms |
1792 KB |
N200000_ex_1 |
AC |
905 ms |
1792 KB |
example_0 |
AC |
1 ms |
256 KB |
example_1 |
AC |
1 ms |
256 KB |
example_2 |
AC |
1 ms |
256 KB |
example_3 |
AC |
1 ms |
256 KB |
rand_0 |
AC |
27 ms |
256 KB |
rand_1 |
AC |
57 ms |
384 KB |
smallrand_0 |
AC |
1 ms |
256 KB |
smallrand_1 |
AC |
1 ms |
256 KB |