Problem J
Drawing Circles
In his first drawing class, a professor assigned a student to draw one circle on a rectangular paper sized $w \times h$ units. The student sat on a comfy bench near Powell Library and was about to start drawing when a terrible thing happened. Although it never rains in LA, they were just in the wrong place at the wrong time. When they ran into Powell Library, there were already $N$ circular droplets of water on the piece of paper.
The student is unable to draw on any part of the paper that is part of a water droplet (i.e. inside the circular region of a droplet), nor are they allowed to draw a circle around a droplet. So, the student decided to draw their circle between the droplets such that it would not intersect with / contain any of the water droplets. After some simple calculations, they figured out all of the coordinates and radii of each water circle on the paper. They also know that if they draw a larger circle, the professor will give them a higher grade. That’s why they kindly ask you to help them figure out the radius of the largest circle they can fit in the piece of paper that does not intersect with any water circles.
The professor will accept an absolute or relative error of $10^{-6}$ in your calculations.
Input
The input starts with one line containing two space-separated real numbers $w$ and $h$ $\left(w,h \leq 10\, 000\right)$, representing the width and height of the rectangular paper. The next line contains an integer $N$ $\left(0 \leq N \leq 500\right)$ denoting the number of water circles.
This is followed by $N$ lines, each containing three space-separated real numbers $x_ i$, $y_ i$, $r_ i$ $\left(0 \leq x_ i \leq w, 0 \leq y_ i \leq h\right)$ representing the coordinates of the center and the radius of $i$-th circle. It’s guaranteed that all circles lie strictly inside the rectangle and it is possible for these circles to intersect / overlap in any manner.
Output
Output one line containing a single number, the radius of the largest circle that can fit in the drawing. Your answer should not exceed an absolute or relative error of $10^{-6}$.
Sample Input 1 | Sample Output 1 |
---|---|
4 2 1 1 1 1 |
1.000000 |
Sample Input 2 | Sample Output 2 |
---|---|
10 10 3 4 4 2 6 6 2 4 4 1.4 |
2.202041028849635 |