問題一覧 > 通常問題

No.355 Number Guessing Game (2)

レベル : / AI推定難易度 : 950 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / リアクティブ問題 (詳しくはこちら)
タグ : (AC するまで非表示) / 解いたユーザー数 127
作問者 : なお
お気に入りにしたユーザー ProblemId : 701 / 自分の提出
問題文最終更新日: 2026-06-25 01:26:46
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 April Contest (順位表) の他の問題:

Problem Statement

You and Taro play a number game.

First, Taro thinks of $4$ digits from $0$ to $9$, without repetition.
He must remember them exactly, including the order of the digits.
The game proceeds as follows.

  1. You choose $4$ digits from $0$ to $9$, without repetition, and tell them to Taro.
  2. Taro tells you "the number of digits that are correct in both value and position" and "the number of digits that are present but in the wrong position".
  3. If you still want to ask, go back to 1. Otherwise, finish.

Guess the $4$ digits Taro thought of within 100 questions.

Hit and Blow

Input and Output

The program you submit (hereafter, the answer program) can output up to 100 question queries to standard output.
However, once you have successfully guessed the $4$ digits Taro thought of, you must not output any further question queries.
The format of a question query is as follows.

$N_1$ $N_2$ $N_3$ $N_4$
$ 0 \leq N_i \leq 9$, and $N_1$ to $N_4$ must be pairwise distinct.

The format of the response to a question query is as follows.
$X$ $Y$
$X$ represents "the number of digits that are correct in both value and position", and
$Y$ represents "the number of digits that are present but in the wrong position".

The response
4 0
to a question query means that the $4$ digits you presented exactly match the $4$ digits Taro thought of.
When this response is returned, Taro will not respond to any more questions, so
terminate the answer program promptly.
In this judge, if you fail to guess correctly even on the 100th question, the verdict becomes incorrect at that point.
Your answer is considered correct if it terminates within the judge's time limit and the response to the last question query was "4 0".

Notes

  • The judge's time limit is 2 seconds, and this includes the response time of the responding program.
  • Output that violates the question query format results in an incorrect verdict.
  • Output to standard error is not considered invalid output.
  • Flush after each output.

Response Sample

Suppose the $4$ digits Taro thought of are the following.

1 3 5 7
In this case, if you output
1 2 3 5
as a question query, then it is judged that
  • $1$ is correct in both value and position
  • $2$ is correct in neither value nor position
  • $3$ and $5$ are present but in the wrong position
and
1 2
is returned as the response.

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