Rafting Design

Time limit1sMemory limit128 MB

Summary
Given an inner polygon fully enclosed by an outer polygon, compute the maximum radius of a circle that can travel all the way around the annular track between them without getting stuck.
Level

Hard8 of 10

Topics
Geometry, Binary search, Graph
Solved
No attempts yet

Problem

Heehyun, the designer of a new rafting project, drew two polygons so that the outer polygon completely contains the inner one, then turned the empty space between them into a rafting track.

Now the size of the circular tube that will float along the track must be decided. The tube has to move and rotate freely all the way around the track, so it must not get stuck anywhere. Heehyun wants the tube to be as large as possible, but if it is too large it will jam in a narrow part of the track.

Find the maximum radius of a circular tube that can travel freely all the way around the track (the region between the two polygons).

Input

The first line contains the number of test cases TT (1≤T≤1001 \le T \le 100).

Each test case is given as follows.

  • The first line contains the number of vertices of the inner polygon nin_i (3≤ni≤1003 \le n_i \le 100), followed by nin_i lines, each containing the coordinates xx yy of a vertex given in order along the polygon.
  • The next line contains the number of vertices of the outer polygon non_o (3≤no≤1003 \le n_o \le 100), followed by non_o lines, each containing the coordinates xx yy of a vertex given in order.

All coordinates are integers with absolute value at most 10001000. The vertices of each polygon are given in clockwise or counterclockwise order. The two polygons neither overlap nor touch, and the outer polygon always completely contains the inner one.

Output

For each test case, print the maximum radius of a circular tube that can move freely around the track, rounded to exactly six digits after the decimal point, one per line.

Examples3

  1. Example 1

    Input
    2
    4
    -5 -5
    5 -5
    5 5
    -5 5
    4
    -10 -10
    -10 10
    10 10
    10 -10
    3
    0 0
    1 0
    1 1
    5
    3 -3
    3 3
    -4 2
    -1 -1
    -2 -2
    
    Expected output
    2.500000
    0.707107
    
  2. Example 2

    Input
    1
    4
    -1 -1
    1 -1
    1 1
    -1 1
    4
    -4 -4
    4 -4
    4 4
    -4 4
    
    Expected output
    1.500000
    
  3. Example 3

    Input
    1
    3
    0 0
    2 0
    0 2
    4
    -4 -4
    4 -4
    4 4
    -4 4
    
    Expected output
    1.000000