Fat Ninjas
InterviewTime limit3sMemory limit128 MB
Given point sensors in an N by N square, find the diameter of the largest circle that can travel from the left side to the right side without touching any sensor.
- Level
Hard8 of 10
- Topics
- Geometry, Union-find, Binary search, Graph
- Solved
- No attempts yet
Problem
A downturn in the contract-killing market has left many ninjas unemployed, sitting at home eating hamburgers and watching game shows. Having grown overweight, they are drawn to a game show that offers a lifetime supply of hamburgers to anyone who can use ninja-like stealth to cross a square hall without triggering any of the strategically placed laser sensors.
The hall is a square region measuring metres. Each laser is mounted on the ceiling and shoots a beam straight down to a sensor on the floor; a beam has zero width and sets off the alarm if a contestant touches its sensor. A contestant must enter from the left side of the hall, move their entire body across, and pass completely through the right side, without ever crossing the top or bottom walls. Merely touching the right side is not enough.
The host wants to place the sensors so that very fat ninjas find it hard to succeed. Given an arrangement of sensors, compute the girth (diameter) of the fattest ninja that can still cross the hall. Assume each ninja is a perfect circle when viewed from above, and that ninjas are too heavy to jump off the floor.
Input
The input contains several game instances. Each instance begins with a line containing two integers and separated by a single space: is the length of the hall's side in metres and is the number of installed lasers (). Each of the next lines contains two integers and separated by a single space, the coordinates of a laser sensor on the floor ().
A line containing two zeros terminates the input and must not be processed.
Output
For each game, output on its own line a single floating-point number: the girth (diameter) of the fattest ninja that can move through the hall without touching any laser sensor. Round the diameter to exactly three decimal places, padding with zeros if necessary.
Rounding rule for a positive value : if the fourth decimal digit is less than , the result is ; otherwise the result is . For example, is written as , and is written as .