QOJ.ac

QOJ

时间限制: 1 s 内存限制: 2048 MB 总分: 100 交互

#14447. 尋寶遊戲

统计

在一個 $5 \times 5$ 的網格中,隱藏著一個 $2 \times 2$ 的寶藏箱。網格的列編號為 1 到 5,行編號亦同,其中儲存格 $(1, 1)$ 為網格的左上角。你的目標是在 5 次詢問內找到寶藏。你可以詢問某個網格儲存格,確認該儲存格內是否包含寶藏箱的任何部分。在最多 5 次詢問後,你必須輸出寶藏箱的左上角座標。

互動

你的程式最多可以針對寶藏的位置進行 5 次詢問。若要進行詢問,請輸出以下格式的新行:

? $i$ $j$

其中 $i$ 和 $j$ 為 1 到 5 之間的整數。你是在詢問第 $i$ 列第 $j$ 行的儲存格是否包含寶藏箱的一部分。每次詢問後,互動器會回應 0(若該儲存格不包含寶藏的任何部分)或 1(若該儲存格包含寶藏的一部分)。

在確定正確答案後,請以以下格式輸出答案:

! $i$ $j$

這代表寶藏箱的左上角座標。輸出答案後,你的程式必須結束。如果你在輸出答案後嘗試讀取回應,將會收到任意判決。

記得在每次輸出詢問後刷新輸出。

如果互動器收到任何無效或非預期的輸入,互動器將輸出 $-1$ 並立即終止。你的程式必須乾淨地結束以獲得正確的判決,否則收到的判決可能是表示提交錯誤的任意判決。

我們提供了一個 Python 測試工具。使用方式如下(你可能需要將 python3 替換為 python):

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

該工具按原樣提供,你可以隨意對其進行修改或擴充。該工具會嘗試偵測並報告常見錯誤,但不保證通過測試工具的程式就一定會被接受。

範例

範例互動 1

讀取 (Read) 寫入 (Write)
? 3 3
0
? 2 2
1
? 1 1
0
? 1 3
1
! 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.