Roof
Time limit1sMemory limit128 MB
Compute the maximum height of the 45-degree straight-skeleton roof built over a rectilinear polygon.
- Level
Hard9 of 10
- Topics
- Geometry
- Solved
- No attempts yet
Problem
You are going to build a new house. To estimate the minimum construction cost of the roof, you first need to know its height. You only have the outline of the house, so you must compute the roof height from that outline.
Here is the precise setup. The outline of the house is a rectilinear polygon: every edge is axis-parallel, either horizontal or vertical. Let be such a polygon with vertices.
The straight skeleton is the trace left by the vertices of as shrinks: every edge moves inward at the same speed while keeping its direction. Figure 1 (a) and (b) show this shrinking process for and the resulting .

Figure 1
Now place on the plane and shrink it at unit speed while simultaneously lifting it upward (the direction) at unit speed. As it moves, sweeps out a three-dimensional polyhedral surface called the terrain, and is exactly the projection of the terrain's edges onto the plane. By construction every face of this terrain lies in a plane that makes a dihedral angle of with the plane, and every face is bounded by at least one edge of . We call this terrain the roof of ; Figure 1 (c) shows it.
The height of a point on the roof is its altitude, that is, the distance between and its projection onto the plane. The height of the roof is the maximum height over all points on it. Your task is to compute the height of the roof of the given rectilinear polygon .
Input
The first line contains the number of test cases .
Each test case begins with a line containing an integer , the number of vertices of the polygon , with . The next line lists the coordinates of the vertices of in counterclockwise order: first the and of the first vertex, then the and of the second vertex, and so on. All values are separated by single spaces, and every coordinate is an integer between and inclusive.
Output
For each test case print exactly one line: the height of the roof of , written with exactly one digit after the decimal point.