Square Annulus
Time limit1sMemory limit128 MB
Given N points, find the minimum width of a concentric axis-parallel square ring that contains all of them.
- Level
Medium7 of 10
- Topics
- Geometry, Binary search, Sorting, Intervals
- Solved
- No attempts yet
Problem
A square annulus is the region that lies between two concentric, axis-parallel squares: two squares that share the same center and whose sides are parallel to the - and -axes. Concretely, it is the set of all points that lie inside the larger square (boundary included) but outside the smaller square (boundary included). The width of a square annulus is defined as half the difference of the side lengths of its two squares.
You are given points in the plane. Find a square annulus of minimum width that contains all points, and report that minimum width.
You may use the following fact, which was established by a German research group.
Among all minimum-width square annuli that contain the points, there is one whose outer square is a smallest axis-parallel square containing the points.
Hence you may assume the outer square of has the smallest possible side length among all axis-parallel squares that contain the points; that is, no axis-parallel square with side length less than contains all of them. Several distinct squares of side length may contain the points, so the outer square is not necessarily unique.
Note that the width can be (when the two squares coincide), and the inner square may shrink to a single point of side length , in which case the width equals half the side length of the outer square.
Input
The first line contains an integer , the number of test cases. The test cases follow one after another.
Each test case begins with a line containing an integer (), the number of points. Each of the next lines contains two integers, the - and -coordinates of one point, separated by a single space. Every coordinate is an integer between and , inclusive. There are no blank lines between consecutive test cases.
Output
For each test case, print one line containing the minimum width of an axis-parallel square annulus that contains all points of that test case. Print the value with exactly one digit after the decimal point, rounding to one decimal place if necessary.