Logo
(追記) (追記ここまで)

29441번 - XOR 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB54373389.189%

문제

Today Paul and Andrew discovered a new operation, XOR of two numbers.

Let us remind you that XOR, or exclusive OR, is a binary operation which is applied to two integer numbers bitwise. For each bit position, if the bits in the arguments are equal, the resulting bit is 0, otherwise 1. For example, 3 XOR 5 $=$ 6, because 3ドル_{10} = 011_2,ドル 5ドル_{10} = 101_2,ドル so if we apply the operation, the second and the third bits are set to 1, bit the first bit is set to 0, so we get 110ドル_{2} = 6_{10}$.

Paul and Andrew liked this operation so much that they invented a game. First, Paul writes $n$ integer numbers $a_i$. Second, Andrew writes $m$ integers $b_j$. After that, Paul finds for each $b_j$ such $k$ that $a_k$ XOR $b_j$ is maximal.

The only problem is that Paul is not very fast in finding these numbers. Help him!

입력

The first line of the input contains one integer $n$ (1ドル \le n \le 100,000$) --- how many numbers Paul wrote. The second line contains Paul's numbers $a_i$ (0ドル \le a_i \le 10^9$). All $a_i$ are different.

The third line contains an integer $m$ (1ドル \le m \le 100,000$) --- how many numbers Andrew wrote. The fourth line contains Andrew's numbers $b_j$ (0ドル \le b_j \le 10^9$).

출력

Output $m$ numbers: for each $b_j,ドル output such $a_k$ that $a_k$ XOR $b_j$ is maximal.

제한

예제 입력 1

2
0 1
2
2 3

예제 출력 1

1 0

예제 입력 2

2
3 0
3
2 3 9

예제 출력 2

0 0 3

힌트

출처

Olympiad > Russian Olympiad in Informatics > Internet Olympiads in Informatics > 2011-2012 Season > February 25, 2012 A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /