QOJ.ac

QOJ

Limite de temps : 2.0 s Limite de mémoire : 512 MB Points totaux : 100 Interactif

#17804. Note Offset Adjustment

Statistiques

"Is playing Dual Star hard? I'm rks 12.66."

As everyone knows, Phigros requires calibration of the note offset. In the distant (or perhaps not so distant) future, Klose-Karl invented a machine that can automatically play Phigros, but she somehow forgot what note offset she set for the machine!

Consequently, she achieved a score of all "Bad" and left the laboratory in a rage. You arrived at the laboratory and saw the machine in a mess. To help Klose-Karl, you decide to secretly measure the machine's note offset.

This is an interactive problem.

The interactor has an integer $x \in [-400, 600]$. Each time, you can query an integer $y \in [-1000, 1000]$, and the interactor will return an answer based on the following conditions:

  • "Perfect": $|x - y| \in [0, 80]$.
  • "Good": $|x - y| \in (80, 160]$.
  • "Bad": $|x - y| \in (160, 180]$.
  • "Miss": $|x - y| \in (180, \infty)$.

You need to return the correct result $x$ within 10 queries.

Interaction

This problem involves multiple test cases.

The first line contains the number of test cases $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 buffer. You must ensure $-1000 \le y \le 1000$, and the current number of queries (including this one) does not exceed 10; otherwise, the interactor will encounter an unknown error.
  • Afterward, read a string $s$ representing the received information.

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

After processing all test cases, terminate the program immediately.

Examples

Input 1

1
Perfect
Good
Miss

Output 1

? 0
? 100
? 200
! 0

Note

When the answer is 0, the results of querying 0, 100, and 200 are as shown in the example.

How to flush the buffer:

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

If you still have questions about interactive problems, a sample code is provided 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 better to do, you can try to figure out how to solve this problem in 9 queries.

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.