#P2498. Hero's Safe Path
Hero's Safe Path
Hero's Safe Path
The hero is about to set off on a quest to rescue Princess Yun, a symbol of love and justice. However, before reaching her, the hero discovers that the boss’s cave – represented as a rectangle with bottom‐left corner at (1,1) and top‐right corner at (R,C) – is swarming with bosses. Realizing that his level is only 1, the hero opts not to confront them head‐on. Instead, he plans to find a continuous path from (1,1) to (R,C) that maximizes the minimum distance from any boss along the way.
More formally, for a candidate safe distance \(d\), define the safe region as all points in the rectangle that are at least \(d\) away from every boss. The objective is to determine the maximum possible \(d\) for which there exists a continuous path from the starting point to the goal that lies entirely within the safe region.
Note: The hero may move in any direction within the rectangle (i.e. the path is not confined to grid points). All formulas in this description are rendered in LaTeX format.
inputFormat
The first line contains three numbers: R, C, and N, where R and C denote the dimensions of the rectangular cave, and N is the number of bosses.
Each of the next N lines contains two real numbers, representing the coordinates of a boss.
outputFormat
Output a single real number: the maximum safe distance (rounded to 6 decimal places) such that there exists a continuous path from (1,1) to (R,C) where every point on the path is at least that distance away from every boss.
sample
5 5 1
3 3
2.828427