#P10642. [BalticOI 2022] Art Collection (Day1)

    ID: 12080 远端评测题 5000ms 2048MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2022交互题Special JudgeBalticOI(波罗的海)

[BalticOI 2022] Art Collection (Day1)

Problem Description

There is an unknown permutation PP with value range [1,n][1,n]. Each time, you may query a permutation RR. The interactive library will return the number of ordered pairs (i,j)(i,j) such that, in permutation PP, ii appears before jj, while in permutation RR, ii appears after jj. You need to determine permutation PP.

Implementation Details

You do not need to include the header file art.h at the beginning of your program. You only need to add the following code at the beginning:

#include <vector>
void answer(std::vector<int>);
int publish(std::vector<int>);

You need to implement a function void solve(int N), which can call the following functions:

  • int publish(std::vector<int> R)
    • This function sends a query permutation RR to the interactive library. RR should be a permutation with value range [1,n][1,n].
    • This function can be called at most 40004000 times.
  • void answer(std::vector<int> R)
    • This function submits your answer to the interactive library, indicating the permutation you have guessed.
    • You must call this function exactly once.

Input Format

The sample interactive library reads the following data from standard input:

The first line contains an integer nn.

The second line contains nn integers, where the ii-th number denotes PiP_i.

If the input format is invalid, it is judged as Invalid input! directly.

Output Format

The sample interactive library outputs the following data to standard input:

After each time you call the public function, the interactive library will output one line describing your interaction.

When you call the answer function, the interactive library will output two lines.

The first line contains nn integers, representing the permutation you answered.

The second line outputs the verdict from the interactive library. If your answer is correct, it will return Correct: x published ranking(s)., where xx is the number of your interactions. Otherwise, it returns Wrong answer!.

Hint

Sample Interaction

Consider the permutation PP is {1,3,2}\{1,3,2\}.

The interaction in the sample is as follows:

Call Return Value Explanation
publish({1, 2, 3}) 1 The valid ordered pair is (3,2)(3,2)
publish({2, 3, 1}) 3 Valid ordered pairs are (1,3),(1,2),(3,2)(1,3),(1,2),(3,2)
answer({1, 3, 2}) The answer matches the correct one

Constraints and Hints

  • Subtask 11 (55 points): N6N \leq 6
  • Subtask 22 (1515 points): N40N \leq 40
  • Subtask 33 (1515 points): N250N \leq 250
  • Subtask 44 (1515 points): N444N \leq 444
  • Subtask 55 (2020 points): N2000N \leq 2000
  • Subtask 66 (3030 points): no special constraints

For all testdata, it holds that 2N40002 \leq N \leq 4000.

Translated by ChatGPT 5