QOJ.ac

QOJ

حد الوقت: 3.0 s حد الذاكرة: 512 MB مجموع النقاط: 100 تفاعلية

#12709. 交互式拦截

الإحصائيات

这是一个交互式问题。

东北紧急火箭控制局(NEERC)开发了一种新的雷达控制系统,旨在更好地控制弹道导弹拦截。为了测试该系统,NEERC 机构开发了一个数学模型,旨在展示该系统的能力。

我们将火箭表示为直线上的一个点。初始时,该点位于 $0$ 到 $p$ 之间(包含 $0$ 和 $p$)的某个未知整数位置。它具有某个未知的速度 $q$,速度 $q$ 是 $0$ 到 $v$ 之间(包含 $0$ 和 $v$)的整数。

每一秒会发生以下过程:首先,控制系统向雷达发出形式为 “check $L$ $R$” 的查询,并获得该点当前是否在 $L$ 到 $R$ 之间(包含 $L$ 和 $R$)的回答。之后,该点的坐标增加 $q$。

雷达控制系统的目标是在某秒开始时获知该点的确切位置。当它获知该点的位置时,不再向雷达发出查询,而是发出拦截该位置点的指令。

你需要实现该控制系统,在最多进行 $100$ 次雷达查询的情况下定位并拦截该点。

交互格式

交互开始时,你的程序需要从标准输入读取两个整数——$p$ 和 $v$ 的值($1 \le p \le 10^5, 1 \le v \le 10^5$)。

之后,你的程序必须向标准输出打印指令。每条指令必须是以下两种之一:

  • “check $L$ $R$” —— 向雷达发出查询,以获得该点当前是否在 $L$ 到 $R$ 之间(包含 $L$ 和 $R$)的回答。回答必须从标准输入读取,为 “Yes” 或 “No”。在此之后,该点的坐标增加 $q$。$L$ 和 $R$ 必须是整数($0 \le L \le R \le 10^9$)。 最多只能有 $100$ 次 “check” 指令。

  • “answer $x$” —— 该点的确切坐标 $x$ 已知,你下令拦截该点。打印此指令后,你的程序必须退出。

你的程序必须在每条指令后写入换行符并刷新标准输出,包括最后一条指令 “answer $x$”(在退出前必须写入换行符并刷新)。

样例

输入 1

2 2
Yes
No
Yes
Yes

输出 1

check 1 3
check 3 5
check 2 4
check 4 5
answer 5

说明

在给出的示例中,该点初始位于位置 $1$,并以速度 $q = 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.