Once upon a time, a special mouse tried to discover a secret permutation . However, he wasn’t able to without using a special device called the “permutation discoverer”. Given some permutation , this device tells him the number of positions for which . He cannot use the device more than a certain number of times though.
More formally, there exists a secret permutation . You can use an operation that returns the number of positions i for which .
Task
Given , using a small enough number of queries, find .
Interaction
This is an interactive problem. The contestant must implement a function void solve(int N)
that eventually finds the hidden permutation p. To do this, include the header grader.h
, and use the function int query(vector<int> q)
. If given a permutation , this function will implement the behavior described earlier. To answer, do a query with a equal to what you think is. If you are correct, the return value will, of course, be N. You must terminate the solve
function after receiving a result from query equal to N.
Constraints
Subtask | Score | Restrictions |
---|---|---|
1 | 13 | |
2 | 38 | |
3 | 49 |
Scoring
Let be the number of queries used in a test. Then the scoring is as follows:
For subtask 1:
- if , points;
- if , points;
- if , points;
- if , points.
For subtask 2: let
- if , then points;
- if , then points;
- if then points;
- if then points;
- If , then points.
For subtask 3: define as in subtask 2
- if , then points.
- if , then
- if , then
NOTE: If the correct permutation is found after too many queries, you will get the verdict “Correct”, with detail “Too many queries”, and points.