Under construction

Still being built. Things may change

Musical Cords

Time limit120sMemory limit1024 MB

Summary
Given N points on a circle, each with a fixed cord length, find the K longest cords, where a cord's length is the two point lengths plus the chord between them.
Level

Medium7 of 10

Topics
Sorting, Heap, Geometry
Solved
No attempts yet

Statement

Lauren is trying to play the most beautiful notes possible using a harp. The harp is a circle with a radius of RR centimeters. To play a note, a cord must be attached to the harp so that it connects two different attachment points on the perimeter of the circle. Lauren then plucks this cord to play a note.

There are NN attachment points on the perimeter of the harp where a cord can be attached. The ii-th attachment point is DiD_i nanodegrees clockwise from the rightmost point of the perimeter, where a nanodegree is 10−910^{-9} degrees.

The attachment points do not all use the same technology. The ii-th attachment point requires LiL_i centimeters of cord for fixing. A cord fixed between two different attachment points ii and jj is exactly Li+Lj+d(i,j)L_i + L_j + d(i, j) centimeters long, where d(i,j)d(i, j) is the length of the chord between points ii and jj, that is, the Euclidean distance between the two points.

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

Input

The first line contains the number of test cases TT. Each test case starts with a line containing three integers NN, RR, and KK: the number of attachment points, the radius of the harp in centimeters, and the number of cord lengths to report. The next NN lines each contain two integers DiD_i and LiL_i, the position in nanodegrees clockwise from the rightmost point and the cord length in centimeters needed at the ii-th attachment point.

Output

For each test case, output one line in the form Case #x: y1 y2 ... yK, where xx is the test case number starting from 1, and yny_n is the nn-th value in the sorted (non-increasing) list of all N×(N−1)/2N \times (N-1) / 2 cord lengths. Each yny_n is correct if it is within an absolute or relative error of 10−910^{-9} of the correct answer.

Limits

  • 1≤T≤1001 \le T \le 100.
  • N=150000N = 150000 in at most 10 cases.
  • 5≤N≤1045 \le N \le 10^4 in all cases where N≠150000N \ne 150000.
  • 1≤R≤1091 \le R \le 10^9.
  • 0≤D10 \le D_1.
  • Di<Di+1D_i < D_{i+1} for all ii.
  • DN<360×109D_N < 360 \times 10^9.

Hint

Cords between different pairs of points may cross each other, since Lauren plays only one note at a time.

Examples1

  1. Example 1

    Input
    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
    
    Expected output
    Case #1: 10.0000000000
    Case #2: 36.9238939618