#BS0000428. Vượt qua hành lang (Getting Through)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Vượt qua hành lang (Getting Through)
Getting Through
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
Ethan must travel from one end of a straight corridor to the other without triggering its sensors. Each sensor detects people or objects entering its detection region. Ethan wants to determine how much equipment he can carry through the corridor while remaining undetected.
Ignoring height, represent the corridor by the strip between the parallel walls and . The two ends are far beyond every sensor, toward and .
There are sensors. Sensor is located at and detects objects in a disk of radius around that point. Its center is inside the corridor or on a wall; its detection region may extend beyond a wall.
Represent Ethan and his equipment (or a robot sent instead) by a disk of radius . The disk may move continuously with arbitrary precision, without crossing a wall or entering any sensor's detection region. Find the greatest radius that can pass through undetected, interpreted as the limiting radius when clearance is just sufficient. If passage is impossible even for arbitrarily small objects, the answer is .
Input
The first line contains an integer , the corridor width.
The second line contains an integer , the number of sensors.
Each of the next lines contains three integers : the horizontal coordinate, vertical coordinate, and detection radius of sensor , respectively.
Output
Print one real number on a single line: the maximum radius, or if passage is impossible. The absolute error from the correct answer must not exceed .
Subtasks
- Subtask 1 (20 points): ; ; ; ; for every .
- Subtask 2 (30 points): ; ; ; ; for every .
- Subtask 3 (50 points): ; ; ; ; for every .
Examples

Input
10
2
2 0 3
7 12 4
Output
1.5
Explanation
The corridor has width . The two sensors have centers and and radii and . The first region meets the left wall, and the second meets the right wall. Their separation is . However, the gap from the second sensor to the left wall is only . A disk with diameter greater than cannot pass this location; a diameter approaching fits the other gaps. The limiting radius is therefore .
Input
10
2
2 0 3
7 8 4
Output
1.216991
Explanation
The sensor radii remain and , but the distance between their centers is now . The gap between their regions is . The regions meet opposite walls. The clearances to their opposite walls are and , both greater than the gap between the two regions. Once this gap closes for the moving disk, a barrier joins the walls. The limiting radius is , printed as 1.216991.
Input
10
2
2 0 3
7 4 4
Output
0
Explanation
The center distance is . The sum of the radii is , so the detection regions overlap. The first meets the left wall, and the second meets the right wall. Together they form a barrier across the corridor, preventing passage even for arbitrarily small objects. The answer is .