Floor Painting
Time limit2sMemory limit256 MB
Find the side length of the largest axis-aligned square that fits inside a given orthogonal simple polygon.
- Level
Hard8 of 10
- Topics
- Geometry, Binary search
- Solved
- No attempts yet
Problem
A museum wants a square painting on the floor of one of its exhibition rooms. Every wall of the room is straight, and two adjacent walls meet at a right angle. Two walls that are not adjacent never touch, and the room has no pillars, so the floor is a simple polygon whose sides are all parallel to the coordinate axes.
The painting is a square. Its four sides must be parallel to the walls, and the whole square must lie inside the floor. The square may touch a wall. The museum wants the painting as large as possible. Find the largest side length it can have.
Input
The first line contains the number of rooms ().
Each room is then given as follows.
- one line with the number of corners ()
- lines, each with two integers and () separated by a space, the coordinates of one corner
The corners are given in clockwise order.
Output
For each room, print one line with a single integer: the largest side length of a square painting that fits on the floor.