QOJ.ac

QOJ

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

#5843. Grazing Google Goats

Statistics

Problem

Farmer John has recently acquired a nice herd of N goats for his field. Each goat i will be tied to a pole at some position Pi using a rope of length Li. This means that the goat will be able to travel anywhere in the field that is within distance Li of the point Pi, 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}, 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 A 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 Qj, you should choose rope lengths so as to minimize the area Aj that can be reached by every goat when the bucket is located at position Qj. You should then calculate each of these areas Aj.

Example

In the picture below, there are four blue points, corresponding to the pole positions: P1, P2, P3, and P4. There are also two red points, corresponding to the potential bucket positions: Q1 and Q2. You need to calculate A1 and A2, the areas of the two shaded regions.

problem_5843_1.png

Input

The first line of the input gives the number of test cases, T. T test cases follow. Each test case begins with a line containing the integers N and M.

The next N lines contain the positions P1, P2, ..., PN, one per line. This is followed by M lines, containing the positions Q1, Q2, ..., QM, one per line.

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

Output

For each test case, output one line containing "Case #x: A1 A2 ... AM", where x is the case number (starting from 1), and A1 A2 ... AM are the values defined above. Answers with a relative or absolute error of at most 10-6 will be considered correct.

Limits

Memory limit: 1GB.

All coordinates are integers between -10,000 and 10,000.

The positions P1, P2, ..., PN, Q1, Q2, ..., QM are all distinct and no three are collinear.

Small dataset (Test set 1 - Visible; 7 Points)

Time limit: 30 5 seconds.

1 ≤ T ≤ 100.

N = 2.

1 ≤ M ≤ 10.

Large dataset (Test set 2 - Hidden; 25 Points)

Time limit: 120 20 seconds.

1 ≤ T ≤ 10.

2 ≤ N ≤ 5,000.

1 ≤ M ≤ 1,000.

Sample

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

Discussions

About Discussions

The discussion section is only for posting: Editorials, 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. Submitting multiple issues may cause your account to be banned.
  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.