#P13073. [GCJ 2020 Finals] Musical Cords

    ID: 12883 Type: RemoteJudge 120000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 7 Uploaded By: Tags>计算几何2020Special JudgeGoogle Code Jam

[GCJ 2020 Finals] Musical Cords

题目描述

Lauren is trying to play the most beautiful notes possible using a harp. The harp is a circle with a radius of R\mathbf{R} centimeters. To play a note, a cord must be attached to the harp in a way that connects two different attachment points on the perimeter of the circle. Lauren then plucks this cord to play a note.

There are N\mathbf{N} attachment points on the perimeter of the circular harp at which a cord can be attached. The ii-th such attachment point is at a location that is Di\mathbf{D}_i nanodegrees (a nanodegree is 10910^{-9} degrees) clockwise around the perimeter of the circular harp, starting from the rightmost point on the perimeter.

Not all attachment points use the same technology to properly fix the cords onto them. The ii-th attachment point requires Li\mathbf{L}_i centimeters of cord to be used for attaching. A cord fixed between two different attachment points ii and jj needs to be exactly $\mathbf{L}_i + \mathbf{L}_j + \text{distance}(i, j)$ centimeters long. By distance(i,j)\text{distance}(i, j) we mean the length of the geometric chord connecting the ii-th and jj-th attachment points, that is, the Euclidean distance between the two points.

Lauren thinks that notes sound better when they come from longer cords. What are the K\mathbf{K} longest cords that can be used with Lauren's harp?

输入格式

The first line of the input gives the number of test cases, T\mathbf{T}. T\mathbf{T} test cases follow. The first line of a test case contains three integers: N\mathbf{N}, R\mathbf{R} and K\mathbf{K}: the number of attachment points, the radius of the circular harp in centimeters, and the number of lengths of cords that Lauren is interested in knowing.

The next N\mathbf{N} lines describe the attachment points. The ii-th of these lines contains two integers, Di\mathbf{D}_i and Li\mathbf{L}_i, which describe the position (in number of nanodegrees clockwise from the rightmost point of the harp) and length of cord in centimeters needed at the ii-th attachment point.

输出格式

For each test case, output one line containing Case #x: y1y_1 y2y_2 ... yKy_{\mathbf{K}}, where xx is the test case number (starting from 1), and yny_n is the nn-th value in the list of lengths of all N×(N1)/2\mathbf{N} \times (\mathbf{N}-1)/2 cords that can be used in Lauren's harp, sorted in non-increasing order.

Each yny_n will be considered correct if it is within an absolute or relative error of 10910^{-9} of the correct answer. See the FAQ for an explanation of what that means, and what formats of real numbers we accept.

2
5 2 1
0 3
1234567890 3
3154510113 3
180000000000 3
359999999999 3
5 10 1
90000000000 8
180000000000 7
260000000000 9
260000000001 1
260000000002 1
Case #1: 10.0000000000
Case #2: 36.9238939618
1
6 1 10
0 10
15000000000 1
30000000000 1
45000000000 1
60000000000 1
75000000000 1
Case #1: 12.2175228580 12.0000000000 11.7653668647 11.5176380902 11.2610523844 3.0000000000 2.7653668647 2.7653668647 2.5176380902 2.5176380902

提示

Sample Explanation

Sample Test Set 1 meet the limits for Test Set 1. Another sample case that does not meet those limits could appear in Test Set 2.

Note: the Li\mathbf{L}_i values in these sample cases for Test Set 1 were chosen for ease of understanding and were not randomly generated. Your solution will be run against these sample cases and must pass them.

In Sample Case #1, all of the attachment points have the same value, so we should pick the pair connected by the longest chord, which in this case is a horizontal diameter of the circle that has a length of 4 centimeters. So the total length needed is 4+3+3=104 + 3 + 3 = 10 centimeters.

In Sample Case #2, the fourth and fifth points are extremely close to the third point, but have much smaller L\mathbf{L} values. We can effectively rule them out and focus on the possible connections among the first three points, as follows:

  • first and second points: length 102+8+729.14213610\sqrt{2} + 8 + 7 \approx 29.142136.
  • first and third points: length 19.923894+8+936.923894\approx 19.923894 + 8 + 9 \approx 36.923894.
  • second and third points: length 12.855726+7+928.855726\approx 12.855726 + 7 + 9 \approx 28.855726.

Using the first and third points gives us the greatest total length.

Sample Test Set 2: Notice that there are three possible pairs of points tied for producing the 9th longest cord. Also, it is fine if lines connecting different pairs of points intersect, since Lauren will only be playing one note at a time.

Limits

  • 1T1001 \leq \mathbf{T} \leq 100.
  • N=150000\mathbf{N} = 150000 in at most 10 cases.
  • 5N1045 \leq \mathbf{N} \leq 10^4 in all cases with N150000\mathbf{N} \neq 150000.
  • 1R1091 \leq \mathbf{R} \leq 10^9.
  • 0D10 \leq \mathbf{D}_1.
  • Di<Di+1\mathbf{D}_i < \mathbf{D}_{i+1}, for all ii.
  • DN<360×109\mathbf{D}_N < 360 \times 10^9.

Test Set 1 (15 Pts, Visible Verdict)

  • Li\mathbf{L}_i is chosen independently and uniformly at random between 1 and 10910^9, inclusive, for each ii.
  • K=1\mathbf{K} = 1.

Test Set 2 (27 Pts, Hidden Verdict)

  • 1Li1091 \leq \mathbf{L}_i \leq 10^9, for all ii.
  • (There is no guarantee as to how each Li\mathbf{L}_i is generated.)
  • K=10\mathbf{K} = 10.