#P8320. Interactive Permutation Recovery
Interactive Permutation Recovery
Interactive Permutation Recovery
This is an interactive problem.
You are given a permutation \( \{a_n\} \) of the integers from 1 to \(n\). For this permutation, define another sequence \( \{d_n\} \) as the prefix maximums, i.e., \[ d_i = \max_{1 \le j \le i} \{a_j\} \] Note that as the permutation \( a \) is modified, \( d \) may also change accordingly.
You can perform two types of operations on the current permutation \( a \):
- Given an index \( i \), query: "How many distinct values are there among \( d_1, d_2, \dots, d_i \)?"
- Given an index \( i \), update: set \( a_i \leftarrow 0 \).
You are allowed to perform no more than 5500 operations in order to fully recover the original permutation \( a \).
Note: The interactive library is static, meaning that the permutation \( a \) does not change during the execution of the interaction.
However, for the purpose of this problem, an offline version is provided. In the offline simulation, the hidden permutation is provided as input and your program should output the original permutation.
inputFormat
The input is given in the following format:
n a1 a2 ... an
Here, n
is the length of the permutation, and a1, a2, ..., an
represent the permutation of the numbers from 1 to n.
outputFormat
Output the recovered permutation in a single line. See the sample output for details.
sample
3
1 2 3
1 2 3