페이지를 불러오는 중…
해결한 사람
1
명
정답률
100.00
%
시간 제한
1000
ms
메모리 제한
2048
MB
The ancient Egyptian computer scientists built several machines that shuffled arrays of integers. Thousands of years later, archaeologists discovered one of their machines and examined it.
The machine takes as input an array of integers and operates in a very predictable manner. It has a built-in permutation of numbers from to that it uses to shuffle the input array. Specifically, is an array of length containing each element between and (inclusive) exactly once.
Because of corrosion, the machine not only shuffles the numbers, but also takes their bitwise XOR with some unknown number . More formally, the machine takes as input an array of length , consisting of non-negative integers. Then, it returns another array of length such that (), where denotes the bitwise XOR operator. Note that is a fixed number, which does not change when you use the machine.
The bitwise XOR of two non-negative integers and is computed as follows. Assume that and have at most bits in their binary representation, that is . Then is a number whose -th bit () is if and only if the -th bit of and is different.
The archaeologists are interested in the built-in permutation . Your task is to find by using the machine. The subtasks in this task impose limits on the number of times you can use the machine and the maximum number you can provide in array .
You should implement the following procedure:
std::vector<int> find_permutation(int N)
The above procedure can make calls to the following procedure:
std::vector<int> use_machine(std::vector<int> A)
Let denote the number of scenarios in a test case. The grader calls the find_permutation procedure once for each scenario.
Let be the maximum allowed number of calls to the procedure use_machine and be the maximum number that can be provided to the machine as input.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 7 | ; |
| 2 | 12 | ; |
| 3 | 19 | ; |
| 4 | 21 | ; |
| 5 | 10 | ; ; is odd |
| 6 | 31 | ; |
Let be the maximum allowed number of calls to the procedure use_machine and be the maximum number that can be provided to the machine as input.
Consider a scenario in which and . The procedure find_permutation is called in the following way:
find_permutation(5)
This procedure may call use_machine([6, 6, 2, 9, 5]), which returns . At this point, it can be deduced that . The procedure may then call use_machine([1, 8, 4, 0, 4]), which returns . At this point, can be deduced and so the procedure should return . In this example, calls are made to the use_machine procedure and the maximum number provided as input to this procedure is .
Consider a scenario in which and . The procedure find_permutation is called in the following way:
find_permutation(5)
This procedure may call use_machine([0, 5, 1, 1, 2]), which returns . Based on this output, can be deduced and so the procedure should return . In this example, only call is made to the use_machine procedure, and the maximum number given as input to the machine is .
The sample grader input starts with a line containing a single integer followed by scenarios in the following format.
N X
P[0] P[1] ... P[N-1]
The sample grader writes the output of the scenarios, each in the following format.
S
R[0] R[1] ... R[S-1]
Q' M'
Here, is the array returned by find_permutation and is its length. is the number of calls to use_machine and is the maximum number provided as input to any of the calls.
N X
P[0] P[1] ... P[N-1]
S
R[0] R[1] ... R[S-1]
Q' M'
2
5 3
0 1 2 3 4
5 8
0 4 3 1 2
5
0 1 2 3 4
2 9
5
0 4 3 1 2
1 5
International Olympiad in Informatics (IOI) 2024, official task package; Korean translation by Reporch.
Reporch에서 한국어 번역, 수식 표기, 이미지 호스팅 및 형식을 수정했습니다.
로그인 상태를 확인하는 중입니다.