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

31684번 - Bitovi 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB22121164.706%

문제

What came first, the chicken or the egg? Is it better to live a hundred years as a millionaire or seven days in poverty? How to become a chess grandmaster? (削除) How to raise blinds? (削除ここまで) How to pass the final exams? How to train a dragon? These are interesting questions we can ponder only after the competition, but now we offer one less interesting computer science problem.

You are given two sets of numbers $A$ and $B$ of size $N$. In one move, you can select an arbitrary element from set $A$ and change one arbitrary digit (bit) in its binary representation. The resulting number must not be an element of set $A$ immediately before the change.

For example, the number 5ドル$ in binary is 0101ドル_2$. In one move, it can become 13ドル = 1101_2,ドル 1ドル = 0001_2,ドル 7ドル = 0111_2,ドル or 4ドル = 0100_2$ if we change its 4ドル$th, 3ドル$rd, 2ドル$nd, or 1ドル$st bit, respectively.

Determine a sequence of moves by which set $A$ becomes equal to set $B$. Sets are equal if they have the same size and there is no element in set $A$ that does not belong to set $B$.

Note: The number of moves does not have to be minimal, but it must satisfy the task constraints.

입력

The first line contains the integer $N$ (1ドル ≤ N ≤ 2^{15}$), the size of the sets $A$ and $B$.

The second line contains $N$ different integers $a_i$ (0ドル ≤ a_i < 2^{15}$), the elements of the set $A$.

The third line contains $N$ different integers $b_i$ (0ドル ≤ b_i < 2^{15}$), the elements of the set $B$.

출력

In the first line, print the number of required moves.

In the remaining lines, print the numbers $x$ and $y$ (0ドル ≤ x, y < 2^{15}$) – we change the number $x$ from set $A$ to the number $y$. The numbers $x$ and $y$ must differ by exactly one bit, and $x \in A$ and $y \not\in A$ must hold at the moment we execute the move.

제한

서브태스크

The number of moves you are allowed to make in all subtasks must not exceed 2ドル^{19}$. It can be shown that a solution always exists within the given constraints.

번호배점제한
110

$a_i , b_i ≤ 2^{14}$

215

$N ≤ 7$

330

$N ≤ 2^7$

415

No additional constraints.

예제 입력 1

3
0 1 2
1 2 3

예제 출력 1

2
1 3
0 1

If we first make the move 0 1, and then 1 3, between these two moves, set $A$ would have two identical elements, which the task does not allow. Another possible solution is 2 3, 0 2.

예제 입력 2

3
4 8 31
0 4 8

예제 출력 2

5
31 30
30 28
28 24
24 16
16 0

31ドル = 11111_2$. By removing bits from least to most significant, we obtain the numbers 30ドル,ドル 28ドル,ドル 24ドル,ドル 16ドル,ドル and 0ドル$ in sequence. After all moves, set $A$ becomes equal to set $B$.

예제 입력 3

5
0 1 2 4 5
7 6 5 3 2

예제 출력 3

9
1 3
3 7
0 1
1 0
2 6
0 2
7 3
5 7
4 5

힌트

출처

Contest > Croatian Open Competition in Informatics > COCI 2023/2024 > Contest #5 2번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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