시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 1 | 0 | 0 | 0.000% |
Once upon a time, a special mouse tried to discover a secret permutation p[1] … p[N]. However, he wasn’t able to without using a special device called the “permutation discoverer”. Given some permutation q[1] … q[N], this device tells him the number of positions i for which p[i] = q[i]. He cannot use the device more than a certain number of times though.
More formally, there exists a secret permutation p[1] … p[N]. You can use an operation query(q[1] … q[N])
that returns the number of positions i for which p[i] = q[i].
Given N, using a small enough number of queries, find p.
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 q, this function will implement the behavior described earlier. To answer, do a query with a q equal to what you think p 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.
Let Q be the number of queries used in a test. Then the scoring is as follows:
번호 | 배점 | 제한 |
---|---|---|
1 | 13 | N ≤ 7 |
2 | 38 | N ≤ 50 |
3 | 49 | N ≤ 256 |
C++17, C++14, C++20, C++14 (Clang), C++17 (Clang), C++20 (Clang)