QOJ.ac

QOJ

Time Limit: 5 s - 20 s Memory Limit: 1024 MB Total points: 32

#5843. 谷歌山羊吃草

Statistics

Farmer John 最近为他的牧场购入了一群 $N$ 只山羊。每只山羊 $i$ 将被系在位置 $P_i$ 的木桩上,绳长为 $L_i$。这意味着山羊可以在距离 $P_i$ 不超过 $L_i$ 的范围内自由活动,但不能超出此范围。(牧场很大且平坦,可以将其视为一个无限的二维平面。)

Farmer John 已经根据上一群山羊的经验选好了木桩位置,但他必须决定绳子的长度。有两个因素使得这个决定变得棘手:

  • 所有的山羊都需要能够到达同一个水桶。Farmer John 尚未决定将水桶放置在哪里。他已经将选择范围缩小到了一组位置 $\{Q_1, Q_2, \dots, Q_M\}$,但他不确定该使用哪一个。
  • 山羊脾气暴躁,当它们聚在一起时,有时会发生吵闹的争斗。为了让大家安心,Farmer John 希望最小化所有山羊都能到达的区域面积 $A$。

遗憾的是,Farmer John 不太擅长几何,他需要你在这部分提供帮助!

对于每个水桶位置 $Q_j$,你需要选择绳长,以最小化当水桶位于位置 $Q_j$ 时,每只山羊都能到达的区域面积 $A_j$。然后,你需要计算出每一个这样的面积 $A_j$。

样例

在下图中,有四个蓝色点,对应木桩位置:$P_1, P_2, P_3$ 和 $P_4$。还有两个红色点,对应潜在的水桶位置:$Q_1$ 和 $Q_2$。你需要计算 $A_1$ 和 $A_2$,即两个阴影区域的面积。

输入格式

输入的第一行给出了测试用例的数量 $T$。接下来是 $T$ 个测试用例。每个测试用例的第一行包含整数 $N$ 和 $M$。

接下来的 $N$ 行包含位置 $P_1, P_2, \dots, P_N$,每行一个。随后是 $M$ 行,包含位置 $Q_1, Q_2, \dots, Q_M$,每行一个。

这 $N + M$ 行中的每一行都包含相应位置的 $x$ 和 $y$ 坐标,中间用单个空格隔开。

输出格式

对于每个测试用例,输出一行,包含 "Case #x: $A_1$ $A_2$ ... $A_M$",其中 $x$ 是用例编号(从 1 开始),$A_1$ $A_2$ ... $A_M$ 是上述定义的面积值。相对误差或绝对误差不超过 $10^{-6}$ 的答案将被视为正确。

数据范围

内存限制:1GB。

所有坐标均为 -10,000 到 10,000 之间的整数。

位置 $P_1, P_2, \dots, P_N, Q_1, Q_2, \dots, Q_M$ 互不相同,且没有三点共线。

小数据集(测试集 1 - 可见;7 分)

时间限制:5 秒。

$1 \le T \le 100$。

$N = 2$。

$1 \le M \le 10$。

大数据集(测试集 2 - 隐藏;25 分)

时间限制:20 秒。

$1 \le T \le 10$。

$2 \le N \le 5,000$。

$1 \le M \le 1,000$。

样例

样例输入 1

3
2 3
0 20
20 0
-20 10
40 20
0 19
4 2
0 0
100 100
300 0
380 90
400 100
1000 5
3 1
0 0
10 10
20 0
10 5

样例输出 1

Case #1: 1264.9865911 1713.2741229 0.2939440
Case #2: 1518.9063729 1193932.9692206
Case #3: 0.0

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.