問題一覧 > 教育的問題

No.3518 Coordinate Guessing Game

レベル : / AI推定難易度 : 115 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / リアクティブ問題 (詳しくはこちら)
タグ : (AC するまで非表示) / 解いたユーザー数 50
作問者 : 👑 p-adic / テスター : 👑 loop0919
お気に入りにしたユーザー ProblemId : 11234 / 自分の提出
問題文最終更新日: 2025-02-16 15:33:32
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 498 リアクティブコンテスト (順位表) の他の問題:

Problem Statement

This is a reactive problem (your program must run interactively with the judge's program).

 

Lattice Point Loving bot is a bot that loves lattice points (points whose coordinates are integers).

Lattice Point Loving bot is located at a lattice point on the number line and keeps its coordinate $X$ secret.

To determine $X$, you perform the following exchange (hereafter called a question) any number of times between $0$ and $2$, inclusive.

  1. First, you choose an integer $x$ satisfying $- 10^3 \leq x \leq 10^3$ and ask for the distance $|x - X|$ between $x$ and $X$ on the number line.
  2. Then, Lattice Point Loving bot answers with $|x - X|$.

After that, find $X$.

Input and Output

First, ask questions any number of times between $0$ and $2$, inclusive. Questions are made using standard input and output in the following format:

  1. First, print ? and an integer $x$ satisfying $- 10^3 \leq x \leq 10^3$, separated by a single-byte space, on $1$ line.
  2. ? $x$
    
  3. Then, $|x - X|$ is given on $1$ line.
  4. $|x - X|$
    

Next, print your answer to this problem to standard output in the following format.

  • Print ! and $X$, separated by a single-byte space, on $1$ line.
  • ! $X$
    

Finally, print a newline.

Constraints

$X$ is not given in the input, but it satisfies the following constraints:

  • $X$ is fixed before all questions. That is, it does not change before or after a question.
  • $X$ is an integer satisfying $-10^3 \leq X \leq 10^3$.

The input satisfies the following constraint:

  • For any integer $x$ satisfying $-10^3 \leq x \leq 10^3$, the input $|x - X|$, which is the reply when asking for the distance between $x$ and $X$, is an integer satisfying $0 \leq |x - X| \leq 2 \times 10^3$.

Notes

If you are not familiar with reactive problems, please also refer to the summary of reactive problems.

In this problem, the judge result is not guaranteed for submissions that do not follow the instructions below:

  • Strictly follow the specified format for output. For example, do not insert extra spaces.
  • Each time you output, add a newline at the end and flush standard output.
  • Terminate your program immediately after printing your answer to this problem.

Sample

The following is an example of an interaction in the situation where $X = 1$.

Input Output Explanation
? 1 You asked for the distance $|1 - X|$ between $1$ and $X$ on the number line.
0 Lattice Point Loving bot answered that $|1 - X| = 0$.
! 1 You answered that $X = 1$. This is correct.

You may ask up to $2$ questions, but it is also fine to answer after only $1$ question, as in this example.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。