Machine

시간 제한1초메모리 제한1024 MB

요약
입력 배열을 순열로 섞고 모든 원소에 숨은 상수 X를 XOR하는 블랙박스 기계를 이용해 순열 P를 알아낸다.
난이도

어려움10점 중 8점

유형
비트 연산, 수학, 구현, 구간
정답자
아직 제출이 없습니다

문제

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 NN integers and operates in a very predictable manner. It has a built-in permutation PP of numbers from 00 to N−1N - 1 that it uses to shuffle the input array. Specifically, PP is an array of length NN containing each element between 00 and N−1N - 1 (inclusive) exactly once.

Because of corrosion, the machine not only shuffles the numbers, but also takes their bitwise XOR with some unknown number XX. More formally, the machine takes as input an array AA of length NN, consisting of non-negative integers. Then, it returns another array BB of length NN such that B\[i]=A\[P\[i]]⊕XB\[i] = A\[P \[i]] \oplus X (0≤i<N0 ≤ i < N), where ⊕\oplus denotes the bitwise XOR operator. Note that XX is a fixed number, which does not change when you use the machine.

The bitwise XOR of two non-negative integers cc and dd is computed as follows. Assume that cc and dd have at most tt bits in their binary representation, that is max⁡(c,d)<2t\max(c, d) < 2^t. Then c⊕dc \oplus d is a number zz whose jj-th bit (0≤j<t0 ≤ j < t) is 11 if and only if the jj-th bit of cc and dd is different.

The archaeologists are interested in the built-in permutation PP. Your task is to find PP 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 AA.

제한

  • 1≤T≤1001 ≤ T ≤ 100
  • 3≤N≤1283 ≤ N ≤ 128
  • 0≤X≤2550 ≤ X ≤ 255
  • 0≤P\[i]<N0 ≤ P \[i] < N for each ii such that 0≤i<N0 ≤ i < N
  • P\[i]≠P\[j]P \[i] \ne P \[j] (for all ii and jj such that 0≤i<j<N0 ≤ i < j < N)

예제

이 문제는 공개된 예제가 없습니다.