QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 2048 MB Puntuación total: 100 Interactivo

#14447. 宝探し

Estadísticas

$5 \times 5$ のグリッド上のどこかに、$2 \times 2$ の宝箱が隠されています。行と列には $1$ から $5$ までの番号が振られており、グリッドの左上のセルは $(1, 1)$ です。あなたの目標は、最大 $5$ 回のクエリで宝箱を見つけることです。グリッドのセルに対してクエリを行い、そのセルに宝箱の一部が含まれているかどうかを尋ねることができます。最大 $5$ 回のクエリの後、宝箱の左上の座標を出力しなければなりません。

Figure 1. A 5x5 grid with a 2x2 treasure chest hidden inside.

インタラクション

あなたのプログラムは、宝箱の場所について最大 $5$ 回のクエリを行うことができます。クエリを行うには、以下の形式で新しい行を出力してください。

? i j

ここで、$i$ と $j$ は $1$ から $5$ までの整数です。これは、$i$ 行 $j$ 列のセルに宝箱の一部が含まれているかを尋ねるものです。各クエリの後、インタラクタは、そのセルに宝箱の一部が含まれていない場合は $0$ を、含まれている場合は $1$ を返します。

正しい答えを特定した後、以下の形式で新しい行に答えを出力してください。

! i j

これは宝箱の左上の座標を指定するものです。答えを出力した後、プログラムは終了しなければなりません。答えを出力した後に応答を読み取ろうとすると、任意の判定(arbitrary verdict)が下されます。

各クエリを出力した後は、必ず出力をフラッシュしてください。

インタラクタが不正または予期しない入力を受け取った場合、インタラクタは $-1$ を出力し、直ちに終了します。正しい判定を受けるためには、プログラムは正常に終了しなければなりません。そうでない場合、受け取る判定は提出が不正であることを示す任意の判定となる可能性があります。

Python で書かれたテストツールが提供されています。以下のように使用してください(環境によっては python3python に置き換える必要があるかもしれません)。

python3 testing_tool.py However-you-run-your-program

このツールは現状のまま提供されており、必要に応じて自由に変更や拡張を行ってください。このツールは一般的なエラーを検出して報告しようとしますが、テストツールに合格したプログラムが必ずしも正解(Accepted)となることは保証されません。

入出力例

入力 1

0
1
0
1

出力 1

? 3 3
? 2 2
? 1 1
? 1 3
! 1 2

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.