Undetected Route
Time limit2sMemory limit256 MB
Find how many leading sensors can stay active before their overlapping circles join the left and right walls and block travel from the bottom edge to the top.
- Level
Medium6 of 10
- Topics
- Union-find, Binary search, Graph, Geometry
- Solved
- No attempts yet
Problem
The Department of Defense has been designing autonomous robots that infiltrate war zones and other hostile places to carry out missions. It now wants to test the latest design, the Penetrator1700, and you are designing the test environment.
The test environment is a rectangular field with sensors placed inside it. Each sensor has a radius that defines the region where it detects a robot. You want the field to hold as many sensors as possible while a route across the field that avoids detection still exists.
The field is the region of the coordinate plane with and . The robot is a point that stays on the field at all times. It starts on the bottom edge (), must finish on the top edge (), and must never come within range of a sensor. There are sensors, each given by three integers , where is a point on the field and is its radius of detection. The sensor circles may overlap, but no circle is tangent to another circle or to the boundary of the field. All sensors start inactive. Find the largest such that the robot has a route across the field when sensors are active, and no route once sensor is active as well. Activating all sensors is guaranteed to leave no route.

Figure: the sensor circles of the first three examples.
Input
The first line holds a positive integer (). Each of the next lines holds three space separated integers , , for one sensor, with . All sensors sit at different positions.
Output
Print a single integer, the largest described above. It may be .