Under construction

Still being built. Things may change

Groundwater Reserves

Time limit1sMemory limit256 MB

Summary
Uniform rain fills a walled polygonal reservoir where each basin spills over its lower rim once full, and the task asks for the highest water surface reached.
Level

Medium7 of 10

Topics
Simulation, Geometry, Sorting
Solved
No attempts yet

Problem

Groundwater is the word for the lakes, ponds, and rivers that form underground. When it rains, part of the water percolates through the layers of soil and rock and ends up in one of those bodies of water somewhere below the surface. Plants with long enough roots draw on groundwater when no rain has fallen for a while, and people reach it by drilling wells deep enough. A drought leaves the reserves partly or completely empty, and refilling them takes a lot of rain.

In this problem the reserves start completely empty, and you compute how far rainfall refills them. The rock at the bottom of the reservoir is given as a polyline through the points (xi,yi)(x_i, y_i). The xx coordinates increase strictly from x1=0x_1 = 0 to xn=1x_n = 1, and no segment is exactly horizontal, so the direction in which the water landing at a point flows is always determined. A point with a larger yy sits higher up, and the sky is at y=+∞y = +\infty. Infinitely high walls stand at x=0x = 0 and x=1x = 1, so no water leaves the map.

Rain falls vertically and evenly over the whole width. A rate of rr means that rr units of water hit each unit of horizontal length per unit of time, so during a duration tt the horizontal interval [a,b][a, b] receives r×t×(b−a)r \times t \times (b - a) units of water. Water that lands on a slope runs downhill into a basin. Once a basin is full, the surplus flows over the lower of the two ridges that bound it and into the next basin. The reservoir starts completely empty.

Find the highest level the water surface reaches anywhere in the reservoir during the tt units of time it rains.

Input

The first line is the number KK of data sets. The KK data sets follow, each in this form.

The first line of a data set holds three numbers nn, rr, tt. The integer nn is the number of points in the reservoir bottom contour, 2≤n≤502 \le n \le 50. The double rr is the rate at which rain falls, 0.0≤r≤1000.00.0 \le r \le 1000.0. The double tt is the duration for which rain falls, 0.0≤t≤1000.00.0 \le t \le 1000.0.

The next line holds 2n2n doubles describing the points of the bottom contour in the order x1 y1 x2 y2 … xn ynx_1\ y_1\ x_2\ y_2\ \dots\ x_n\ y_n. It is guaranteed that 0=x1<x2<x3<⋯<xn=10 = x_1 < x_2 < x_3 < \dots < x_n = 1 and −1000.0≤yi≤1000.0-1000.0 \le y_i \le 1000.0. Two neighboring points never share the same yy value.

Output

For each data set, print Data Set x: on a line by itself, where xx is its number counting from 1.

On the next line, print the highest level the water surface reached anywhere in the reservoir, rounded to exactly two digits after the decimal point. A basin that holds no water counts as having its surface at the height of its floor.

Print a blank line after each data set.

Examples2

  1. Example 1

    Input
    2
    9 1.0 1.0
    0 2 0.25 -4 0.5 2 0.6 0 0.65 -4 0.7 0 0.75 -4 0.8 0 1 1
    8 0.5 2
    0 0 0.2 2 0.4 0 0.6 1 0.7 0.5 0.8 1.5 0.9 1 1 2
    
    Expected output
    Data Set 1:
    0.40
    
    Data Set 2:
    2.00
    
  2. Example 2

    Input
    2
    2 1.0 1.0
    0 0 1 1
    2 1.0 1.0
    0 1 1 0
    
    Expected output
    Data Set 1:
    1.50
    
    Data Set 2:
    1.50