QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 256 MB 満点: 100 ハック可能 ✓

#7241. 黑色安息日

統計

考虑一个大小为 $w \times h$ 的二维矩形馅饼。建立坐标系,使得馅饼的四个角分别为 $(0, 0), (w, 0), (w, h)$ 和 $(0, h)$。馅饼中包含 $n$ 颗樱桃。每颗樱桃由一个半径为 $r_i$ 的圆表示,且完全位于馅饼内部。任意两颗樱桃之间互不重叠、互不接触,且不与馅饼边界接触。

你邀请了 $n-1$ 位客人参加聚会,加上你一共 $n$ 个人。现在是切开并享用馅饼的时候了!如果一个人得到了一块严格凸多边形的馅饼碎片,且该碎片内部严格包含一颗樱桃,那么这个人就会感到满意。碎片的大小和形状无关紧要,樱桃的大小也无关紧要。如果一个多边形满足:对于其内部任意两点 $a$ 和 $b$,连接它们的整个线段 $[a, b]$ 也在该多边形内部,且多边形的任意三点不共线,则称该多边形为严格凸多边形。

你花了大量时间制作这个精美的馅饼,所以你不希望浪费任何一块。因此,你需要将馅饼切成恰好 $n$ 块,并满足上述规则,且不留下任何多余的部分。你的任务是找到任意一种切法。

输入格式

第一行包含三个整数 $w, h$ 和 $n$ ($4 \le w, h \le 10^4, 1 \le n \le 1000$),分别表示馅饼的大小和樱桃的数量。

接下来的 $n$ 行,每行包含三个整数 $x_i, y_i, r_i$ ($1 \le r_i \le \frac{\min\{w,h\}}{2} - 1, r_i + 1 \le x_i \le w - r_i - 1, r_i + 1 \le y_i \le h - r_i - 1$),表示第 $i$ 颗樱桃的圆心坐标及其半径。

保证任意两颗不同樱桃之间的距离至少为 $0.1$。

输出格式

按照输入中樱桃的顺序,输出包含每颗樱桃的 $n$ 块碎片的描述。每段描述必须以一个整数 $k$ ($k \ge 3$) 开头,表示构成该碎片的严格凸多边形的边数。随后输出 $k$ 行,按逆时针顺序给出多边形顶点的坐标。

建议输出所有浮点数时,小数点后保留不少于 9 位数字。校验程序将至少使用 80 位浮点运算执行以下检查:

  • 每块碎片的每条边长度必须至少为 $10^{-4}$。
  • 每块碎片任意两条相邻边之间的内角不得大于 $\pi - 10^{-11}$ 弧度。每块碎片的顶点必须按逆时针顺序给出。
  • 所有碎片的总面积必须在 $[(1 - 10^{-9}) \cdot w \cdot h, (1 + 10^{-9}) \cdot w \cdot h]$ 范围内。
  • 樱桃上每一点到包含该樱桃的碎片边界的距离必须至少为 $10^{-4}$。
  • 一块碎片上的点可以属于另一块碎片,但在这种情况下,该点到第二块碎片边界的距离最多为 $10^{-4}$。
  • 碎片上的点可以位于馅饼外部,但在这种情况下,该点到馅饼边界的距离最多为 $10^{-4}$。
  • 所有碎片边数的总和最多为 $2 \cdot 10^4$。

样例

输入 1

12 10 5
3 2 1
9 2 1
6 5 2
3 8 1
9 8 1

输出 1

5
0.0 0.0
6.0 0.0
6.0 1.0
1.5 5.0
0.0 5.0
5
6.0 0.0
12.0 0.0
12.0 5.0
10.5 5.0
6.0 1.0
4
6.0 1.0
10.5 5.0
6.0 9.0
1.5 5.0
5
0.0 5.0
1.5 5.0
6.0 9.0
6.0 10.0
0.0 10.0
5
12.0 10.0
6.0 10.0
6.0 9.0
10.5 5.0
12.0 5.0

说明

如果你最终解决了比赛中的所有问题,并且感到孤独和无聊,可以要求出题人给你一个 $n \le 10^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.