Task
The Scientific Committee has hidden from you a permutation of all the integers from to . You need to find it. Permutation is fixed (the grader is not adaptive).
Interaction protocol
Your solution to this problem must be written inside this function:
void solve(int N);
You are free to write and call additional functions but you're not allowed to write a main()
function.
In your endeavor, you are allowed to ask queries that take as parameter another permutation of all the integers from to :
int query(std::vector<int> V);
This function will return . Whenever you want to perform a query, call this function with a permutation of all the integers from to as parameter. You will be graded based on the number of times you call this function. Performing a number of queries, you are to discover permutation , or any other permutation ' that is indistinguishable from .
When you're confident you've discovered permutation , call this function with as a parameter.
void answer(std::vector<int> P);
Calling this function will terminate the program.
Note that both permutations and are represented as a -indexed std::vector<int>
when supplied as parameters.
Sample implementation
Sample code to illustrate the Interaction section:
#include "permutation.h"
void solve(int N) {
if (N == 2) {
std::vector<int> V = {1, 2};
int qAns = query(V);
if (qAns == 1) {
std::vector<int> P = {1, 2};
answer(P);
}
}
}
Sample grader
For local testing you can download two files from "Attachments": grader.cpp and permutation.h.
The Grader reads from Standard Input an integer - the size of the hidden permutation and distinct integers - the hidden permutation. Then, the Grader calls the solve()
function you must implement.
At Standard Output the Grader will output:
- for every
query()
call: the queried permutation and the answer to the query; - for the
answer()
call: the verdict (Correct or Wrong Answer), and - the size of the permutation and the number of queries you used.
Constraints and clarifications
- Two permutations are indistinguishable if queried in all possible ways they both yield the same answers.
# | Points | Restrictions |
---|---|---|
1 | 15 | |
2 | 35 | |
3 | 50 |
Scoring
Each of the test cases is scored as follows:
If you fail to discover one of the correct permutations, then of the score is awarded.
Otherwise, let be the number of queries you needed to solve the test case.
- If then of the score is awarded.
- If queries then (between and , increasing as decreases) of the score is awarded.
- If queries then (between and , increasing as decreases) of the score is awarded.
- If then of the score is awarded.
The total score of this task will be rounded to decimal places.