#P10642. [BalticOI 2022] Art Collection (Day1)
[BalticOI 2022] Art Collection (Day1)
Problem Description
There is an unknown permutation with value range . Each time, you may query a permutation . The interactive library will return the number of ordered pairs such that, in permutation , appears before , while in permutation , appears after . You need to determine permutation .
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 to the interactive library. should be a permutation with value range .
- This function can be called at most 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 .
The second line contains integers, where the -th number denotes .
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 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 is the number of your interactions. Otherwise, it returns Wrong answer!.
Hint
Sample Interaction
Consider the permutation is .
The interaction in the sample is as follows:
| Call | Return Value | Explanation |
|---|---|---|
publish({1, 2, 3}) |
1 | The valid ordered pair is |
publish({2, 3, 1}) |
3 | Valid ordered pairs are |
answer({1, 3, 2}) |
The answer matches the correct one |
Constraints and Hints
- Subtask ( points):
- Subtask ( points):
- Subtask ( points):
- Subtask ( points):
- Subtask ( points):
- Subtask ( points): no special constraints
For all testdata, it holds that .
Translated by ChatGPT 5