mouse

Time limit: 0.75s Memory limit: 128MB Input: Output:

Once upon a time, a special mouse tried to discover a secret permutation p1,,pnp_1, \dots, p_n. However, he wasn’t able to without using a special device called the “permutation discoverer”. Given some permutation q1,qnq_1, \dots q_n, this device tells him the number of positions ii for which pi=qip_i = q_i. He cannot use the device more than a certain number of times though.

More formally, there exists a secret permutation p1,pnp_1, \dots p_n. You can use an operation query(q1,qn)query(q_1, \dots q_n) that returns the number of positions i for which pi=qip_i = q_i.

Task

Given NN, using a small enough number of queries, find pp.

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 qq, this function will implement the behavior described earlier. To answer, do a query with a qq equal to what you think pp 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 N7N \leq 7
2 38 N50N \leq 50
3 49 N256N \leq 256

Scoring

Let QQ be the number of queries used in a test. Then the scoring is as follows:

For subtask 1:

  • if Q50Q \leq 50, 1313 points;
  • if 50<Q20050 < Q \leq 200, 99 points;
  • if 200<Q5 040200 < Q \leq 5 \ 040, 66 points;
  • if Q>5 040Q > 5 \ 040, 00 points.

For subtask 2: let Q=(Q/100+1)100Q \rq = (\lfloor Q / 100 \rfloor + 1) * 100

  • if Q400Q \rq \leq 400, then 3838 points;
  • if 400<Q700400 < Q \rq \leq 700, then (3829)(700Q)/(700400)+29(38-29) \cdot (700-Q \rq) / (700-400) + 29 points;
  • if 700<Q1 300700 < Q \rq \leq 1 \ 300 then (2921)(1 300Q)/(1 300700)+21(29-21) \cdot (1 \ 300-Q \rq) / (1 \ 300-700) + 21 points;
  • if 1 300<Q10 0001 \ 300 < Q \rq \leq 10 \ 000 then (214)(10 000Q)/(10 0001 300)+4(21-4) \cdot (10 \ 000-Q \rq) / (10 \ 000-1 \ 300) + 4 points;
  • If 10 000<Q10 \ 000 < Q \rq, then 00 points.

For subtask 3: define QQ \rq as in subtask 2

  • if Q2 400Q \rq \leq 2 \ 400, then 4949 points.
  • if 2 400<Q5 0002 \ 400 < Q \rq \leq 5 \ 000, then (4929)(5 000Q)/(5 0002 400)+29(49 - 29) * (5 \ 000 - Q \rq) / (5 \ 000 - 2 \ 400) + 29
  • if 5 000<Q5 \ 000 < Q \rq, then 00

NOTE: If the correct permutation is found after too many queries, you will get the verdict “Correct”, with detail “Too many queries”, and 00 points.

Log in or sign up to be able to send submissions!