RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00671

Bitovi

Unrated 레이팅 미적용
난이도
1s
시간 제한
512MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

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 01012. In one move, it can become \(13 = 11012\), \(1 = 00012\),
\(7 = 0111\){2}, or \(4 = 0100\) if we change its 4th, 3rd, 2nd, or 1st 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.

제약

Subtask 1 (10 points): \(a\)\(i\), b\(i \le 2^{14}\)

Subtask 2 (15 points): \(N \le 7\)

Subtask 3 (30 points): \(N \le 2^{7}\)

Subtask 4 (15 points): No additional constraints.

입력 형식

The first line contains the integer \(N\) (\(1 \le N \le 2^{15}\)), the size of the sets \(A\) and \(B\).
The second line contains \(N\) different integers \(a@@RISE_MATH_BLOCK_0@@i < 2^{15}\)), the elements of the set \(A\).
The third line contains \(N\) different integers \(b@@RISE_MATH_BLOCK_1@@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 \le 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\)\(A\) and \(y\) /∈\(A\) must hold at
the moment we execute the move.

서브태스크
서브태스크점수설명

1

10점

\(a\)\(i\), b\(i \le 2^{14}\)

2

15점

\(N \le 7\)

3

30점

\(N \le 2^{7}\)

4

15점

No additional constraints.

예제 1
입력
3
0 1 2
1 2 3
출력
2
1 3
0 1
예제 2
입력
3
4 8 31
0 4 8
출력
5
31 30
30 28
28 24
24 16
16 0
예제 3
입력
5
0 1 2 4 5
7 6 5 3 2
출력
9
1 3
3 7
0 1
1 0
2 6
0 2
7 3
5 7
4 5
설명

Clarification of the first example:
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.
Clarification of the second example:
31 = 111112. 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.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2023/2024 Contest 5

평가 및 의견

Bitovi

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Bitovi

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8