#P13073. [GCJ 2020 Finals] Musical Cords
[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 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 attachment points on the perimeter of the circular harp at which a cord can be attached. The -th such attachment point is at a location that is nanodegrees (a nanodegree is 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 -th attachment point requires centimeters of cord to be used for attaching. A cord fixed between two different attachment points and needs to be exactly $\mathbf{L}_i + \mathbf{L}_j + \text{distance}(i, j)$ centimeters long. By we mean the length of the geometric chord connecting the -th and -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 longest cords that can be used with Lauren's harp?
输入格式
The first line of the input gives the number of test cases, . test cases follow. The first line of a test case contains three integers: , and : 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 lines describe the attachment points. The -th of these lines contains two integers, and , 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 -th attachment point.
输出格式
For each test case, output one line containing Case #x: ... , where is the test case number (starting from 1), and is the -th value in the list of lengths of all cords that can be used in Lauren's harp, sorted in non-increasing order.
Each will be considered correct if it is within an absolute or relative error of 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 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 centimeters.
In Sample Case #2, the fourth and fifth points are extremely close to the third point, but have much smaller 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 .
- first and third points: length .
- second and third points: length .
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
- .
- in at most 10 cases.
- in all cases with .
- .
- .
- , for all .
- .
Test Set 1 (15 Pts, Visible Verdict)
- is chosen independently and uniformly at random between 1 and , inclusive, for each .
- .
Test Set 2 (27 Pts, Hidden Verdict)
- , for all .
- (There is no guarantee as to how each is generated.)
- .