#P12531. [XJTUPC 2025] Beat Verdict: Precision Strike
[XJTUPC 2025] Beat Verdict: Precision Strike
Description
This is an interactive problem.
You are playing a music game. In expert mode, you need to accurately calibrate the timing parameter for hitting notes, which is a mysterious within the range .
To determine this parameter, you can perform at most calibration tests. In each test, you choose an test value (), and the system will inform you whether is true or not. Ultimately, you need to provide an estimated parameter value (), such that .
Note: The final estimated value does not count towards the aforementioned maximum of tests.
Input Format
The input contains multiple test cases. The first line of the data contains an integer () indicating the number of test cases. The interaction process for each test case is described below.
In each test case, the first line of input contains a positive integer (), representing the possible range of the parameter.
If you want to perform a calibration test, output (). Then you will read the response to that test, which will be an integer (), where indicates that is true, and indicates that is false.
If you want to submit the calibration parameter , output (). You will then immediately end the interaction for this test case and prepare for the interaction of the next test case. This interaction does not count towards the maximum of tests.
Note that at the end of each round of output in your program (i.e., after each output of or ), $\textbf{you need to output a newline and flush the output buffer}$; otherwise, you will receive .
You can use:
- C's ;
- C++'s ;
- Java's ;
- Python's ;
to flush the output buffer.
Please note: The interactive library is adaptive, meaning that the positive integer () in each test case, but it will always satisfy all previously made inquiries.
If the answer you output at the end is correct, you will receive ;
If your inquiries do not conform to the problem's range requirements, or if the final answer you output is incorrect, you will receive ;
Additionally, other evaluation results will still be returned during the evaluation process based on normal circumstances.
Output Format
See also interactive format.
2
1
8
1
1
0
0
! 1
? 6
? 4
? 2
? 3
! 3
Hint
In the first test case, it can be uniquely determined that , so we directly submit .
In the second test case, the hidden parameter , and the interaction process is as follows:
- Test , the response is that is true;
- Test , the response is that is true;
- Test , the response is that is false;
- Test , the response is that is false;
- Submit .
Please note that this example only serves to demonstrate the interaction format. It is not guaranteed that the queries provided are optimal or uniquely determine the answer.
京公网安备 11011102002149号