QOJ.ac

QOJ

実行時間制限: 5 s メモリ制限: 512 MB 満点: 100

#3019. 探测机器人

統計

在霍斯(Hoth)驻扎后,你决定这是你做过的最糟糕的决定。这颗行星寒冷无比,无事可做,更糟糕的是,帝国不断派遣探测机器人下来查看是否有人藏在行星上。至少你可以对这些探测机器人做点什么!

你的基地附近的区域以均匀的方式布满了这些机器人。你的基地位于该区域的西南(左下)角,坐标为 $(1, 1)$。在 $n \times m$ 的网格中,其余每个格点(具有整数坐标的点)上都有一个机器人。

一个 $3 \times 5$ 网格的示例如下:

注意,第 1 行在底部,第 $n$ 行在顶部;第 1 列在左侧,第 $m$ 列在右侧。

你的基地位于坐标 $(1, 1)$,而机器人位于范围 $(1..n, 1..m)$ 内的所有正坐标点上,当然不包括 $(1, 1)$。你的基地上有一座炮塔,初始朝向东方,即朝向第 1 行中列号更大的方向。你编写的炮塔运行逻辑如下:如果视线内有机器人,则摧毁该机器人。否则,逆时针旋转炮塔,直到它能看到一个机器人。重复此过程,直到所有机器人被摧毁。

你的任务是找出当炮塔执行该算法时,第 $i$ 个被摧毁的机器人。

输入格式

每个输入包含一个测试用例。注意,你的程序可能会在不同的输入上运行多次。每个测试用例的第一行包含三个整数 $n, m$ ($1 \le n, m \le 10^6$, $m$ 和 $n$ 不能同时为 1) 和 $q$ ($1 \le q \le 100$),其中网格有 $n$ 行 $m$ 列,共有 $q$ 个查询需要回答。接下来的 $q$ 行,每行包含一个整数 $i$ ($1 \le i < n \times m$),表示对第 $i$ 个被摧毁机器人的查询。

输出格式

输出 $q$ 行,依次对应 $q$ 个查询。对于每个查询,输出两个整数 $r$ 和 $c$,中间用空格分隔,分别表示第 $i$ 个被摧毁机器人的行号 $(r)$ 和列号 $(c)$。

样例

输入 1

3 5 3
1
14
8

输出 1

1 2
3 1
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.