#P13402. [GCJ 2010 #2] Grazing Google Goats

    ID: 15271 远端评测题 3000~12000ms 1024MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>计算几何2010Special Judge凸包Google Code Jam

[GCJ 2010 #2] Grazing Google Goats

题目描述

Farmer John has recently acquired a nice herd of NN goats for his field. Each goat ii will be tied to a pole at some position PiP_i using a rope of length LiL_i. This means that the goat will be able to travel anywhere in the field that is within distance LiL_i of the point PiP_i, but nowhere else. (The field is large and flat, so you can think of it as an infinite two-dimensional plane.)

Farmer John already has the pole positions picked out from his last herd of goats, but he has to choose the rope lengths. There are two factors that make this decision tricky:

  • The goats all need to be able to reach a single water bucket. Farmer John has not yet decided where to place this bucket. He has reduced the choice to a set of positions {Q1,Q2,,QM}\{Q_1, Q_2, \ldots, Q_M\}, but he is not sure which one to use.
  • The goats are ill-tempered, and when they get together, they sometimes get in noisy fights. For everyone's peace of mind, Farmer John wants to minimize the area AA that can be reached by all the goats.

Unfortunately, Farmer John is not very good at geometry, and he needs your help for this part!

For each bucket position QjQ_j, you should choose rope lengths so as to minimize the area AjA_j that can be reached by every goat when the bucket is located at position QjQ_j. You should then calculate each of these areas AjA_j.

Example

In the picture below, there are four blue points, corresponding to the pole positions: P1P_1, P2P_2, P3P_3, and P4P_4. There are also two red points, corresponding to the potential bucket positions: Q1Q_1 and Q2Q_2. You need to calculate A1A_1 and A2A_2, the areas of the two shaded regions.

输入格式

The first line of the input gives the number of test cases, TT. TT test cases follow. Each test case begins with a line containing the integers NN and MM.

The next NN lines contain the positions P1,P2,,PNP_1, P_2, \ldots, P_N, one per line. This is followed by MM lines, containing the positions Q1,Q2,,QMQ_1, Q_2, \ldots, Q_M, one per line.

Each of these N+MN + M lines contains the corresponding position's xx and yy coordinates, separated by a single space.

输出格式

For each test case, output one line containing "Case #xx: A1A_1 A2A_2 ... AMA_M", where xx is the case number (starting from 1), and A1A_1 A2A_2 ... AMA_M are the values defined above. Answers with a relative or absolute error of at most 10610^{-6} will be considered correct.

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
Case #1: 1264.9865911 1713.2741229 0.2939440
Case #2: 1518.9063729 1193932.9692206
Case #3: 0.0

提示

Limits

  • All coordinates are integers between 10,000-10,000 and 10,00010,000.
  • The positions P1,P2,,PN,Q1,Q2,,QMP_1, P_2, \ldots, P_N, Q_1, Q_2, \ldots, Q_M are all distinct and no three are collinear.

Small dataset (7 Pts, Test set 1 - Visible)

  • Time limit: 30 3 seconds.
  • 1T1001 \leq T \leq 100.
  • N=2N = 2.
  • 1M101 \leq M \leq 10.

Large dataset (25 Pts, Test set 2 - Hidden)

  • Time limit: 120 12 seconds.
  • 1T101 \leq T \leq 10.
  • 2N5,0002 \leq N \leq 5,000.
  • 1M1,0001 \leq M \leq 1,000.