# ARC092：Two Sequences（二进制 & 二分）

### Problem Statement

You are given two integer sequences, each of length Na1,…,aN and b1,…,bN.

There are N2 ways to choose two integers i and j such that 1i,jN. For each of these N2 pairs, we will compute ai+bj and write it on a sheet of paper. That is, we will write N2 integers in total.

Compute the XOR of these N2 integers.

Definition of XOR

### Constraints

• All input values are integers.
• 1N200,000
• 0ai,bi<228

### Input

Input is given from Standard Input in the following format:

N
a1 a2 … aN
b1 b2 … bN


### Output

Print the result of the computation.

### Sample Input 1

Copy
2
1 2
3 4


### Sample Output 1

Copy
2


On the sheet, the following four integers will be written: 4(1+3),5(1+4),5(2+3) and 6(2+4).

### Sample Input 2

Copy
6
4 6 0 0 3 3
0 5 6 5 0 3


### Sample Output 2

Copy
8


### Sample Input 3

Copy
5
1 2 3 4 5
1 2 3 4 5


### Sample Output 3

Copy
2


### Sample Input 4

Copy
1
0
0


### Sample Output 4

Copy
0

# include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 2e5+30;
LL a[maxn], b[maxn], ans=0;
int main()
{
int n, l, r;
scanf("%d",&n);
for(int i=0; i<n; ++i) scanf("%lld",&a[i]);
for(int i=0; i<n; ++i) scanf("%lld",&b[i]);
for(int i=28; ~i; --i)
{
LL s = 1LL<<i, tmp=0;
for(int j=0; j<n; ++j) a[j]&=(s<<1)-1, b[j]&=(s<<1)-1;
sort(b,b+n);
for(int j=0; j<n; ++j)
{
l = lower_bound(b,b+n,s-a[j])-b;
r = lower_bound(b,b+n,(s<<1)-a[j])-b;
tmp += r-l;//不进位
l = lower_bound(b,b+n,(s<<1|s)-a[j])-b;
r = lower_bound(b,b+n, (s<<2)-a[j])-b;
tmp += r-l;//进位
}
if(tmp&1) ans |= s;
}
printf("%lld\n",ans);
return 0;
}