This page is still under construction.

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

Corridor

Time limit1sMemory limit128 MB

Summary
Find the largest radius of a sphere that can travel west to east through a corridor, where point pillars and the two side walls block it.
Level

Hard8 of 10

Topics
Graph, Shortest path, Geometry, Union-find
Solved
No attempts yet

Problem

There is a rectangular corridor whose width (west–east) is mm and whose depth (south–north) is nn. Several pillars of negligible size (treated as points) stand inside the corridor, and each pillar rises vertically from the floor to the ceiling.

You want to roll a perfectly spherical ball through the corridor from its west side to its east side. The ball may start anywhere on the west side and may exit at any position on the east side. The corridor is so tall that the ball never touches the ceiling.

Write a program that finds the radius of the largest ball that can pass through the corridor.

Input

The first line contains the corridor's width mm and depth nn. The second line contains the number of pillars kk. Each of the next kk lines contains one pillar's coordinates in the form x y, where xx is the west–east coordinate and yy is the south–north coordinate. (0≤n,m,k≤10000 \le n, m, k \le 1000)

The west–east axis points from west to east, so a smaller xx is farther west and a larger xx is farther east. The south–north axis points from south to north, so a smaller yy is farther south and a larger yy is farther north. All coordinates are integers, and every pillar lies inside the corridor, so 0≤x≤m0 \le x \le m and 0≤y≤n0 \le y \le n.

Output

Print the radius of the largest ball that can pass through the corridor, to eight digits after the decimal point (pad with trailing zeros if needed).

Examples3

  1. Example 1

    Input
    5 2
    1
    1 1
    
    Expected output
    0.50000000
    
  2. Example 2

    Input
    5 2
    0
    
    Expected output
    1.00000000
    
  3. Example 3

    Input
    10 10
    1
    5 5
    
    Expected output
    2.50000000