#P10642. Guess the Hidden Permutation

    ID: 12669 Type: Default 1000ms 256MiB

Guess the Hidden Permutation

Guess the Hidden Permutation

You are given an unknown permutation \(P\) of size \(n\) with values ranging from \(1\) to \(n\). You can ask queries by providing another permutation \(R\) of \([1,n]\). The interactive library will return the number of ordered pairs \((i,j)\) such that in permutation \(P\), \(i\) appears before \(j\), while in permutation \(R\), \(i\) appears after \(j\).

Your task is to determine the hidden permutation \(P\>.

Implementation Details

  • You do not need to include the header file art.h at the beginning of your program.
  • You must add the following code at the top of your submission:
#include <vector>
void answer(std::vector<int>);
int publish(std::vector<int>);

You need to implement a function void solve(int N). In your function you can call the following functions:

  • int publish(std::vector<int> R): This function sends a query with permutation \(R\) to the interactive library. \(R\) should be a permutation of \([1,n]\). You are allowed to call this function at most 4000 times.
  • void answer(std::vector<int> R): This function submits your guess for the permutation \(P\) to the interactive library. You must call this function exactly once.

Note: For the purpose of testing, a simple strategy (such as returning the identity permutation) may be used. In the sample test cases provided, the hidden permutation \(P\) is the identity permutation.

inputFormat

Format:

The first line of input contains an integer \(N\) representing the size of the permutation. In the sample test cases the hidden permutation \(P\) is provided as the second line (for simulation purposes), but you should ignore it in your submission.

outputFormat

Format:

Output your guessed permutation as \(N\) space-separated integers on one line.

Interaction Protocol: In an interactive environment, you are expected to call the publish function for queries and then call answer exactly once with your final guess. For the testing purposes here, simply output the result.

sample

3
1 2 3
1 2 3