QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 512 MB Points totaux : 100 Interactif Hackable ✓

#16732. 更冷-更热

Statistiques

这是一个交互式问题。

Egor 和 Petr 正在二维平面上玩一个名为“Colder-Hotter”(忽冷忽热)的游戏。在游戏开始时,Egor 心中想好了一个坐标为非负整数且不超过 $10^9$ 的点。然后 Petr 尝试去猜这个点:在第 $i$ 轮中,他选择一个整点坐标 $(x_i, y_i)$ 并告诉 Egor。如果这个点相比于上一个点 $(x_{i-1}, y_{i-1})$ 距离被猜的点更近,那么 Egor 回答 “1”。否则,以及在游戏的第一轮时,他回答 “0”。

当没有剩余轮数,或者 Petr 认为他已经有足够的信息时,他会停止游戏并给出他的答案。如果答案正确,Petr 被视为获胜者。随着 Petr 变得越来越有经验,Egor 减少了游戏轮数的限制。

目前他们游戏中轮数的限制是 $500$。Petr 请求你写一个程序来成功击败 Egor。

Egor 是一个诚实的玩家,在游戏开始后不会改变点的位置。

输入格式

裁判程序会输出 “1”(当玩家当前给出的点相比于上一个点距离被猜的点更近时),或者 “0”(当玩家当前给出的点不比上一个点更近,或者不存在上一个点时)。

输出格式

如果玩家进行一轮猜测,他必须输出两个整数,中间用单个空格分隔 —— 即所说点的 $x$ 和 $y$ 坐标($0 \le x, y \le 10^9$)。如果玩家想要停止游戏,他必须输出字符 'A',然后输出两个整数 —— 即猜出的点的 $x$ 和 $y$ 坐标,然后停止程序。

在每次输出(一次猜测或答案)之后,你必须输出一个换行符,刷新输出流,并读取回答。如果你不知道如何执行刷新(flush)命令,请参阅说明。如果你的程序在标准输入中收到 EOF(文件结束)信号,它必须立即退出,退出码为 0。不遵守此要求可能会导致 “Time Limit Exceeded” 错误。

保证被猜的点的坐标是非负的且不超过 $10^9$。

样例

输入样例 1

0
0
1
0
1
0

输出样例 1

1 1
0 0
20 20
20 20
17 239
17 240
A 17 239

说明

样例中被猜的点是 $(x = 17, y = 239)$。游戏的一种可能进行过程如下:

  1. Petr 给出点 $(1, 1)$,Egor 回答 0,因为这是第一轮。
  2. Petr 现在给出点 $(0, 0)$,它比 $(1, 0)$ 距离 $(x = 17, y = 239)$ 更远,因此 Egor 再次回答 0。
  3. 下一个点是 $(20, 20)$,此时回答为 1。
  4. 现在 Petr 再次给出 $(20, 20)$,只是为了向你展示这种情况下的回答是 0,因为“更近”这一关系是反自反的。
  5. 现在 Petr 意外地给出了点 $(17, 239)$,但 Egor 并没有说这就是答案:根据游戏规则,他只是说这个点比上一个点距离被猜的点更近。
  6. Egor 对 $(17, 240)$ 回答 0。
  7. Petr 决定碰碰运气,给出了点 $(17, 239)$。注意,他实际上还没有足够的信息来确定,所以他只是碰巧猜对了。

要刷新标准输出流,请使用以下语句:

在 C 中,使用 fflush(stdout); 在 C++ 中,使用 cout.flush(); 在 Java 中,使用 System.out.flush();

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.