The new leadership of the national committee, represented by the coordinators of groups A and B, wishes to maintain a strict syllabus of the given problems for selecting the national team. For this purpose, they will need to give a geometry problem. Moreover – the number of interactive problems given so far are below standard. To fix the crisis in the selection for IOI, Sashka decided to give a problem that is both interactive and geometric. It has the following statement:
The jury has hidden a permutation of . You must find the permutation. For this purpose, you may ask the jury the following question: “Is it possible to form a triangle with positive area with sides ?”
Note that it is known (by the triangle inequality) this is possible if and only if: and
Write a program triangle, containing a function solve, which will be compiled together with the jury program and will communicate with it by asking questions of the type described above. At the end of its execution, it must determine the permutation.
Implementation details
You should implement the solve function:
std::vector<int> solve(int N)
- : length of the permutation.
This function will be called times per test – once per subtest, each with equal and it should return the hidden permutation for the subtest. In order to do this, your program can call the jury function query:
bool query(int A, int B, int C)
- : indices of the sides .
The function returns true, if a triangle with positive area with sides exists and false, otherwise.
Constraints and clarifications
| Subtask | Points | Description |
|---|---|---|
| 1 | 100 | The subtask consists of 1 test with randomly and uniformly sampled from the set of all possible permutations, each of |
Scoring
Let be the average number of queries that your program for one call of solve on the single test, and let . Then your score for the problem will be:
Sample interaction
| Contestant action | Jury action |
|---|---|
solve(4) |
|
query(0, 0, 0) |
true |
query(0, 1, 2) |
false |
query(0, 1, 3) |
false |
query(0, 2, 3) |
true |
query(1, 2, 3) |
false |
return {3, 1, 2, 4}; |
|
solve(4) |
|
query(0, 1, 2) |
false |
query(0, 1, 3) |
true |
query(0, 2, 3) |
false |
query(1, 2, 3) |
false |
return {4, 2, 1, 3}; |
Local testing
Input format:
- line : three integers , , and – the number of subtests, the size of the permutations, and the execution mode. If , the local grader will generate uniformly random permutations and will expect a number on the second line – , which will be the seed for its random generator. If , the input continues as follows:
- lines to : permutations of .
Output format:
- line : an error message or the average