QOJ.ac

QOJ

时间限制: 2.0 s 内存限制: 256 MB 总分: 100 交互

#9382. 循环搜索

统计

这是一个交互式问题。

小丽莎在一个教育网站上学习数学。她刚刚又解决了一堆问题,作为奖励,她照例获得了一个新游戏。这一次,游戏规则如下。

屏幕上画着一个坐标平面。图中勾勒出一个以点 $(0, 0)$ 和 $(n, n)$ 为对角顶点的正方形。游戏会秘密选择该正方形内或其边界上的一个整数坐标点。玩家必须找到这个秘密点。为此,玩家可以在平面上放置一个圆,通过选择一个整数坐标点作为圆心,并选择一个非负整数作为半径。之后,游戏会告诉玩家这个圆是否包含该秘密点(在圆内或圆周上)。当玩家在秘密点处放置一个半径为 $0$ 的圆时,游戏结束。

丽莎玩了几次游戏,在经过漫长的一轮后,她想知道:当 $n$ 很大时,如何快速找到秘密点?

请解决丽莎问题的通用版本。已知数字 $n$,通过在平面上放置圆,快速找到秘密点。

交互

首先,在单独的一行中给出一个整数 $n$ ($1 \le n \le 10\,000$)。之后,玩家可以放置 $0$ 到 $50$ 个圆。

要放置下一个圆,请在单独的一行中打印三个整数:“$x\ y\ r$”。其中 $x$ 和 $y$ 是圆心的坐标,而 $r$ 是其半径 ($-10^9 \le x, y \le +10^9$, $0 \le r \le 10^9$)。作为回答,玩家会得到一行包含一个单词的反馈:“Yes”(如果秘密点在圆内或圆周上)或“No”(否则)。

在得到半径为 $0$ 的圆的“Yes”反馈后,请优雅地终止程序。如果在放置了 $50$ 个圆后仍未发生这种情况,系统将尝试以“Wrong Answer”结果终止运行。

为了防止输出缓冲,请在打印每一行后刷新输出缓冲区:例如,在 C 或 C++ 中使用 fflush(stdout),在 Java 中使用 System.out.flush(),在 Pascal 中使用 flush(output),或者在 Python 中使用 sys.stdout.flush()

在每个测试中,秘密点的坐标是预先固定好的,并且在游戏过程中不会改变。

样例

输入 1

1
No
Yes
Yes

输出 1

0 0 1
1 1 1
1 1 0

说明 1

秘密点为 $(1, 1)$。

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.