This page is still under construction.

Parts of this page are still being built. What you see may change.

Intervals

Time limit1sMemory limit128 MB

Summary
Given a point light above the x-axis and non-overlapping circular pipes below it, find the shadowed intervals on the x-axis, sorted and rounded to two decimals.
Level

Hard8 of 10

Topics
Geometry, Sorting, Intervals, Implementation
Solved
No attempts yet

Problem

A point light source is mounted in the ceiling of a basement, and the floor is very sensitive to light. To protect the floor, we want to know which parts of it lie in shadow — that is, which parts receive no light because a pipe blocks the source.

The situation is modeled in 2D. The x-axis coincides with the floor. The light is a point source with integer coordinates (bx,by)(b_x, b_y). Each pipe under the ceiling is modeled as a circle: pipe ii has integer center (ci,x,ci,y)(c_{i,x}, c_{i,y}) and integer radius rir_i. Because the pipes are solid, the circles never overlap; a pipe neither reflects light nor lets light pass through it.

Write a program that determines the non-overlapping intervals on the x-axis that receive no light from the source because they are shadowed by the pipes.

Input

The input consists of several blocks; each block except the last describes one situation in the basement.

The first line of a block contains an integer NN with 0<N<5000 < N < 500, the number of pipes. The second line contains two integers bxb_x and byb_y, separated by a single space, giving the coordinates of the light source. Each of the following NN lines contains three integers ci,xc_{i,x}, ci,yc_{i,y} and rir_i (with ci,y+ri<byc_{i,y} + r_i < b_y), separated by single spaces, describing one pipe.

The last block consists of a single line containing N=0N = 0; it terminates the input and is not processed.

Output

For each input block (except the terminating one), output the intervals of the floor that receive no light. Print each interval on its own line as two real numbers — the left and right endpoints — separated by a single space and rounded to exactly two decimal places. Within a block the intervals are sorted by increasing x-coordinate. The results of two consecutive blocks are separated by a single empty line.

Examples1

  1. Example 1

    Input
    6
    300 450
    70 50 30
    120 20 20
    270 40 10
    250 85 20
    220 30 30
    380 100 100
    1
    300 300
    300 150 90
    1
    300 300
    390 150 90
    0
    
    Expected output
    0.72 78.86
    88.50 133.94
    181.04 549.93
    
    75.00 525.00
    
    300.00 862.50