#P16126. [USTCPC 2026] Note Offset Adjustment

    ID: 18119 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>交互题Special Judge2026高校校赛

[USTCPC 2026] Note Offset Adjustment

Background

“Is Double Star hard? I rks12.66.”

As everyone knows, Phigros needs chart delay calibration. In a far, yet maybe not so far future, Cruxkarl-chan invented a machine that can automatically play Phigros, but she actually forgot what chart delay was set on the machine.

As a result, she got the “great” achievement of all Bad, got angry, and left the lab. You came to the lab and saw the machine in a total mess. To help Cruxkarl-chan, you decide to secretly measure the machine’s chart delay.

Problem Description

This is an interactive problem.

The interactive library has an integer x∈[−400,600]x\in [-400,600]. Each time, you can query an integer y∈[−1000,1000]y\in [-1000,1000], and then the library returns an answer based on the following cases:

  1. Perfect: ∣x−y∣∈[0,80]|x-y|\in [0,80].
  2. Good: ∣x−y∣∈(80,160]|x-y|\in (80,160].
  3. Bad: ∣x−y∣∈(160,180]|x-y|\in (160,180].
  4. Miss: ∣x−y∣∈(180,∞)|x-y|\in (180,\infty).

You need to output the correct result xx within 1010 queries.

Interaction Method

This problem has multiple testdata.

The first line contains the number of test cases T(1≤T≤1000)T (1\le T\le 1000).

For each test case:

When you need to make a query:

  • Output in the format ? y and flush the output buffer. You must ensure −1000≤y≤1000-1000\le y\le 1000, and the current number of queries (including this one) does not exceed 1010. Otherwise, the interactive library may encounter an unknown error.

  • Then, read a string ss representing the returned message.

When you have obtained the answer, output in the format ! x and flush the output buffer.

After processing all test cases, terminate the program immediately.

1

Perfect

Good

Miss

? 0

? 100

? 200

! 0

Hint

When the answer is 00, the results of querying 0,100,2000,100,200 are as shown in the sample.

How to flush the output buffer:

  • In C and C++, use fflush(stdout) (if you use printf\text{printf}) or cout.flush() (if you use cout\text{cout}).
  • In Python, use stdout.flush().
  • In particular, in C++, using cout<<endl will automatically flush the buffer.

If you still have questions about interactive problems, a sample code is shown below:

#include<stdio.h>
#include<string.h>
#include<iostream>
int main(){
	int t; cin>>t;
    while(t--){
        cout<<"? "<<0<<endl;
        string s;cin>>s;
        printf("0\n"); fflush(stdout);
    }
	return 0;
}

If you have nothing to do, you can try to solve this problem within 99 queries.

Translated by ChatGPT 5