eolymp
bolt
Try our new interface for solving problems
Problems

Getting Through

Getting Through

A long and straight corridor is fitted with a number of sensors. Each sensor has a certain range within which it can detect objects or persons. If a part of an object is within the sensor’s range, an alarm will go off. Otherwise, nothing will happen. Ethan needs to traverse this corridor in order to do some spy stuff at the other end. The question is, can he pass through the corridor without being detected? Can he fit so easily that he can bring some equipment along, or does he have to wear some tight clothing? Or can he perhaps sent a robot through instead? We model the corridor as being two-dimensional (we ignore the height), bounded by two straight lines. Each sensor is located inside the corridor or on a wall. Their scopes are well in between the two ends of the corridor. We model the person or robot going through as a circle. Given the layout, what is the maximum radius this circle can have so that it is possible to negotiate the corridor without being detected? \includegraphics{https://static.e-olymp.com/content/47/47c37f5c3482af62f400583dda9448636415fe26.jpg} A visual representation of the samples. \InputFile On the first line one positive number: the number of test cases, at most \textbf{100}. After that per test case: \begin{itemize} \item one line with a single integer \textbf{w} (\textbf{1} ≤ \textbf{w} ≤ \textbf{100000}): the width of the corridor. The two walls are given by the lines \textbf{x = 0} and \textbf{x = w}. \item one line with a single integer \textbf{n} (\textbf{0} ≤ \textbf{n} ≤ \textbf{1000}): the number of sensors in the corridor. \item \textbf{n} lines with three space-separated integers \textbf{x}, \textbf{y} and \textbf{r} (\textbf{0} ≤ \textbf{x} ≤ \textbf{w}, \textbf{-100000} ≤ \textbf{y} ≤ \textbf{100000} and \textbf{1} ≤ \textbf{r} ≤ \textbf{100000}): the location and the range of each sensor, respectively. \end{itemize} The two ends of the corridor are at \textbf{y = -1} and \textbf{y = +1}, or in less technical terms, they are far beyond the scope of all the sensors. \OutputFile Per test case: \begin{itemize} \item one line with one floating point number: the radius of the largest circular object (or person) that could pass through the corridor without being detected, assuming the object can (be) move(d) with absolute precision. If nothing could possibly get through, the output should be zero. \end{itemize} The number should be accurate up to \textbf{10^\{-6 \}}absolute precision.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3
10
2
2 0 3
7 12 4
10
2
2 0 3
7 8 4
10
2
2 0 3
7 4 4
Output example #1
1.5
1.216991
0
Source The 2013 Benelux Algorithm Programming Contest, BAPC 2013