QOJ.ac

QOJ

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

#11790. 最终关卡

統計

Fiora 是一位游戏设计师,她正在为她的新游戏设计最终关卡。

该游戏的关卡是一个矩形网格上的迷宫,里面有很多敌人。玩家从方格 $(0, 0)$ 出发,目标是到达方格 $(a, b)$。Fiora 有很多关于如何放置敌人的想法,但她不喜欢设计迷宫。她需要你的帮助。

Fiora 使用一个特殊的关卡编辑器来设计关卡,该编辑器支持一种用于设计迷宫的基本块。这种块是一个 L 型拐角,由两个 $1 \times n$ 的矩形在 $1 \times 1$ 的方格处相交而成。该块可以进行四种旋转。块与块之间不能重叠,但可以接触。玩家可以穿过任何块内的所有方格。如果两个方格共享一条边,即使它们位于不同的块中,玩家也可以在它们之间移动。

n=3 时的块,第一个样例,第二个样例

Fiora 希望用最少数量的块来设计最终关卡。当然,必须能够从方格 $(0, 0)$ 移动到方格 $(a, b)$。

输入格式

输入的第一行包含一个整数 $m$ ($1 \le m \le 100$),表示测试用例的数量。接下来是 $m$ 个测试用例。每个测试用例占一行,包含三个整数 $a, b$ 和 $n$ ($-10^8 \le a, b \le 10^8; 2 \le n \le 10^8$),其中 $a$ 是终点在水平轴上的坐标,$b$ 是终点在垂直轴上的坐标,$n$ 是块的大小。终点与起点不同(即 $a \neq 0$ 或 $b \neq 0$)。

输出格式

对于每个测试用例,第一行输出所需的最小块数 $k$。在接下来的 $k$ 行中,打印这些块的描述。每个 L 型拐角块由两个单元格的坐标描述。打印其垂直矩形末端的坐标,然后打印其水平矩形末端的坐标。指定与矩形交点相对的末端坐标。注意,块描述中单元格的顺序很重要,因为顺序的改变会导致块的镜像。每个末端的坐标应先打印水平轴坐标,后打印垂直轴坐标。

输出中的所有坐标绝对值不得超过 $10^9$。

保证所有测试用例中正确输出的块总数不超过 $10^5$。

样例

输入 1

2
2 3 2
4 -1 3

输出 1

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