QOJ.ac

QOJ

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

#7027. 加工盘式转子

統計

Edward 是 Aluminum Cyclic Machinery 的一名工人。他的工作是控制机械臂切割模具材料。以下是对他工作的简要介绍。

假设操作面板是一个带有坐标系的欧几里得平面。最初,模具是一个圆心在 $(0, 0)$、半径为 $R$ 的圆盘。Edward 控制 $n$ 个不同的机械臂,将模具中位于其影响区域内的部分切割并移除。第 $i$ 个机械臂的影响区域是一个圆心在 $(x_i, y_i)$、半径为 $r_i$ 的圆。为了获得高质量的产品,保证任意两个机械臂的影响区域互不相交,且没有任何一个影响区域包含整个原始模具。

你的任务是确定剩余模具的直径。在此,欧几里得平面上一个子集(该子集可能不是凸集)的直径是指该子集中任意两点之间距离的上限(即最小上界)。下图展示了样例的示意图。

输入格式

输入包含多个测试用例,第一行包含一个正整数 $T$,表示测试用例的数量,最多为 $5000$。

对于每个测试用例,第一行包含两个整数 $n$ 和 $R$,其中 $1 \le n \le 100$,$1 \le R \le 1000$。

接下来的 $n$ 行描述了 Edward 控制的所有机械臂,第 $i$ 行包含三个整数 $x_i, y_i$ 和 $r_i$,描述了第 $i$ 个机械臂的影响区域,其中 $-1000 \le x_i, y_i \le 1000$ 且 $1 \le r_i \le 1000$。

输出格式

对于每个测试用例,输出一行 “Case #x: y”,其中 $x$ 是从 1 开始的测试用例编号,$y$ 是剩余区域的直径,绝对误差或相对误差不超过 $10^{-9}$。准确地说,假设你的答案为 $a$,评测答案为 $b$,如果满足 $\frac{|a-b|}{\max\{1,|b|\}} \le 10^{-9}$,则你的答案被认为是正确的,其中 $\max\{x, y\}$ 表示 $x$ 和 $y$ 中的最大值,$|x|$ 表示 $x$ 的绝对值。

样例

输入 1

1
3 10
0 12 10
11 -6 10
-11 -6 10

输出 1

Case #1: 18.611654895000252

说明

在样例中,剩余区域的直径为 $\sqrt{324 + \frac{162\sqrt{471}}{157}} \approx 18.611654895000253$,这等于 $(-8, 6)$ 与 $(\frac{11}{2} - \frac{27\sqrt{471}}{157}, -3 - \frac{99\sqrt{471}}{314})$ 之间的距离。

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.