QOJ.ac

QOJ

Time Limit: 4 s Memory Limit: 2048 MB Total points: 100 Interactive

#5134. 锯齿状天际线

Statistics

未来已来!Boxes And Parcels 中心决定开始使用无人机运送包裹。作为一家 BrAinPort 公司,首批交付地点自然是埃因霍温(Eindhoven)。

为了简化飞行逻辑,第一个原型机将只负责向最高建筑的屋顶运送包裹。起飞后,无人机将拍摄一张 $w \times h$($1 \le w \le 10\,000$,$1 \le h \le 10^{18}$)的城市天际线照片,如图 J.1 所示。你的任务是确定这张照片中最高建筑的位置和高度,以便无人机知道目的地。

图 J.1:样例交互的天际线。

你可以使用一个分类器来判断每个像素是“天空”(sky)还是“建筑”(building)。你可以对不同的像素多次使用该分类器。为了避免不必要的延迟,你最多可以运行该分类器 $12\,000$ 次。

题目保证建筑不会包含任何悬空部分:每当照片中非底部的像素被分类为建筑时,其下方的像素也一定会被分类为建筑。

交互

这是一个交互式问题。你的提交将与一个交互器进行交互,交互器读取你程序的标准输出,并向你的标准输入写入数据。此交互需要遵循特定的协议:

交互器首先发送一行,包含两个整数 $w$ 和 $h$($1 \le w \le 10\,000$,$1 \le h \le 10^{18}$),分别表示照片的宽度和高度(以像素为单位)。

然后,你的程序应进行最多 $12\,000$ 次查询以找到最高建筑。每次查询通过打印一行格式为 ? x y($1 \le x \le w$,$1 \le y \le h$)的内容来完成。交互器将回复 skybuilding,表示坐标 $(x, y)$ 处像素的分类。

当你确定了其中一座最高建筑的 $x$ 坐标及其高度 $y$ 后,打印一行格式为 ! x y 的内容,随后交互将结束。打印答案不计入查询次数。

交互器是非自适应的:天际线在开始时即已固定,不会根据你的查询而改变。

如果存在多个有效解,你可以输出其中任意一个。

请确保在每次写入后刷新缓冲区。

提供了一个测试工具来帮助你开发解决方案。

使用超过 $12\,000$ 次查询将导致错误答案。

样例

样例输入 1

10 6
sky
building
sky
building

样例输出 1

? 1 1
? 3 5
? 7 3
? 9 2
! 3 5

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.