This page is still under construction.

Parts of this page are still being built. What you see may change.

Safe Distance

Time limit1sMemory limit512 MB

Summary
Find the widest path from (0,0) to (X,Y) inside an axis-aligned rectangle with N point obstacles, maximizing the minimum distance to any obstacle.
Level

Medium7 of 10

Topics
Binary search, Geometry, Union-find, Graph
Solved
No attempts yet

Problem

The past year has been difficult, with a virus spreading among the population. Fortunately, Alice knows that one of the keys to staying healthy is to keep a safe distance from other people.

Alice is currently in a closed room, represented in the 2D2D plane, with width XX and height YY. There are NN other people inside the room, and we are given their coordinates (xi,yi)(x_i, y_i).

We consider Alice and the NN people as points in the 2D2D plane. Alice's initial position is (0,0)(0, 0) and she wants to move to the exit at position (X,Y)(X, Y). She can move freely in any direction inside the room, but she cannot step outside the room bounds.

Find the maximum distance Alice can keep from other people while moving from (0,0)(0, 0) to (X,Y)(X, Y).

Input

The input begins with one line containing two space-separated integers, XX and YY, where XX is the width and YY is the height of the room. The second line consists of a single integer NN, the number of people in the room. Then NN lines follow, each of them consisting of two floating-point numbers xix_i and yiy_i, the coordinates of the ii-th person in the room.

Output

The output consists of a single value dd, the maximum safe distance, as a floating-point number.

An additive or multiplicative error of 10−510^{-5} is tolerated: if dd is the answer, any number either within [d−10−5;d+10−5][d - 10^{-5}; d + 10^{-5}] or within [(1−10−5)d;(1+10−5)d][(1 - 10^{-5})d ;(1 + 10^{-5})d] is accepted.

Constraints

  • 1≤X,Y≤1 000 0001 \le X, Y \le 1\,000\,000
  • 1≤N≤1 0001 \le N \le 1\,000
  • 0≤xi≤X0 \le x_i \le X
  • 0≤yi≤Y0 \le y_i \le Y

Examples1

  1. Example 1

    Input
    8 6
    3
    3 1
    3 5.5
    6.5 1.5
    
    Expected output
    2.250000