QOJ.ac

QOJ

حد الوقت: 5 s حد الذاكرة: 512 MB مجموع النقاط: 100 تفاعلية

#10231. Moving Company

الإحصائيات

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:

  1. Start() returns $3$.
  2. Test(A) with A = [1, 2, 3] results in A = [1, 1, -1].
  3. Test(A) with A = [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.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.