This is an interactive problem.
You are leading a moving company composed of giants to help a tycoon move. You have $n$ giants, labeled $1, 2, \dots, n$, where giant $i$ can only carry objects weighing $i$ tons or less. The tycoon has $n$ pieces of furniture to be moved, also labeled $1, 2, \dots, n$, with exactly one piece of furniture weighing $i$ tons for each $i \in \{1, \dots, n\}$. Obviously, the moving process can only proceed smoothly when each giant $i$ is assigned to carry the furniture weighing $i$ tons. Unfortunately, you have no weighing equipment and cannot distinguish the weight of the furniture by its appearance. The only thing you can do is issue instructions, requiring giant $A_i$ to carry furniture $i$, such that each giant carries exactly one piece of furniture.
- If giant $i$ carries furniture weighing less than $i$ tons, they will lift it above their head; if giant $i$ carries furniture weighing exactly $i$ tons, they will hold it at their waist; if giant $i$ carries furniture weighing more than $i$ tons, they can only place it on the ground.
- If every giant holds their furniture at their waist, the test is successful, and the moving process proceeds smoothly; otherwise, based on the giants' performance, you can decide and issue the next test instruction.
- Special note: To avoid annoying the tycoon, you have at most $20$ opportunities to issue test instructions.
Task
This problem only supports C++.
You need to include the header file remover_c.h.
You need to implement the main function, and you can call the following functions:
long Start();
- This function must be called exactly once at the very beginning.
- The return value of this function is $n$.
void Test(TA &A);
- $\texttt{TA}$ is a predefined array type. You need to write your instructions into array $\texttt{A}$, where $\texttt{A[i]}$ represents the giant you want to assign to carry furniture $i$. You must ensure that $\texttt{A}$ is a permutation of $1$ to $n$.
- This function will write the results into array $\texttt{A}$. $\texttt{A[i]} = -1$ means furniture $i$ was lifted above the head, $\texttt{A[i]} = 0$ means furniture $i$ was held at the waist, and $\texttt{A[i]} = 1$ means furniture $i$ was placed on the ground. Specifically, if this test is successful, the grader will terminate the program immediately. You must not terminate the program yourself.
- If the test is still not successful after $20$ calls to
Test, the grader will also terminate the program.
Sample Grader
See the attachment for download.
Input Format
The first line contains an integer $n$.
The second line contains $n$ integers, where the $i$-th integer $w_i$ represents the weight of item $i$. $w$ must be a permutation of $1$ to $n$.
Output Format
If you succeed within $20$ tests, the grader will output a line like OK! cnt=x, where $x$ is the number of Test instructions you used.
Otherwise, the interactive grader will output the reason for the error.
Examples
Input 1
3 2 3 1
Output 1
OK! cnt=2
Note
The following is a successful interaction:
Start()returns $3$.Test(A)withA = [1, 2, 3]results inA = [1, 1, -1].Test(A)withA = [2, 3, 1]results in success, and the grader exits.
Constraints
- For $30\%$ of the data: $1 \leq n \leq 10$.
- For $60\%$ of the data: $1 \leq n \leq 100$.
- For $100\%$ of the data: $1 \leq n \leq 1000$.
It is guaranteed that during a valid interaction, the grader will not consume more than $0.1\texttt{s}$ of time and $16\texttt{MB}$ of memory.
The interactive grader is not adaptive.