QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 512 MB 總分: 100

#16090. 飞行安全

统计

在规划飞行航线时,安全是一个至关重要的问题。首先,当然应该采取一切可能的措施,确保旅途平安无事,不发生任何意外。但即便如此,人们也应该随时做好最坏的打算,并尽力确保一旦发生意外,人们的生还几率能够尽可能高。

在水上进行紧急迫降时,到最近陆地的距离是一个关键因素。一般来说,在开阔水域上距离陆地越远,生还的几率就越低。因此,飞行的一个重要安全参数是:在整个飞行过程中,航线上的点距离最近陆地的最大距离。你的任务是编写一个程序,在给定飞行航线的情况下,确定这个最大距离。

为了简化问题,我们将世界建模为一个二维平面,而不是球体。我们将大陆建模为多边形,将飞行航线建模为由线段连接的一系列关键点。飞行航线总是严格在某个大陆内部开始和结束,但中间的关键点可能位于水域上。大陆之间不会自交,也不会相互接触。

第二个样例(最远点用正方形标记)。

输入格式

第一行包含一个正整数:测试用例的数量,最多为 100。接下来是每个测试用例的数据:

  • 第一行包含两个整数 $C$ ($1 \le C \le 20$) 和 $N$ ($2 \le N \le 20$),其中 $C$ 是大陆的数量,$N$ 是飞行航线中关键点的数量。
  • 接下来 $N$ 行,每行包含两个整数 $X, Y$,按从先到后的顺序给出关键点的坐标。
  • 接下来是 $C$ 个大陆的描述。每个大陆的描述首先包含一行,有一个整数 $M$ ($3 \le M \le 30$),表示该大陆的顶点数。紧接着是 $M$ 行,每行包含一对整数 $X, Y$,按顺时针或逆时针顺序给出这 $M$ 个顶点的坐标。

输入中的所有坐标都在 $-10\,000$ 到 $10\,000$ 之间。

输出格式

对于每个测试用例:

  • 输出一行,表示飞行航线距离陆地的最远距离。答案的绝对误差或相对误差应在 $10^{-3}$ 以内。

样例

输入样例 1

2
1 2
-9 -6
5 1
3
0 16
-16 -12
17 -6
2 3
12 4
16 17
3 9
4
1 0
4 19
19 14
6 12
3
10 10
5 3
18 2

输出样例 1

0.000000
2.942685

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.