Given a simple polygon whose edge lengths and angles are bounded, decide whether two radius-4 disks can be placed inside it without touching each other.
Medium7GeometryBinary searchImplementationNo attempts yetTime limit2sMemory limit512 MBYou are about to plant a pair of fine kiwi trees on your large property. You are worried that the branches will grow beyond the boundary of your property and make your neighbours complain. You must also avoid planting the two trees so close to each other that their branches grow into each other, because that could lead to a loss of fruit.
The seller of the trees guaranteed that no branch or leaf will be farther than 4 meters from the trunk of its tree, so we model each tree as a circle of radius 4 meters. The trunks are perfectly vertical.
Local government regulations forbid certain shapes of properties. So that government employees can draw and handle maps of the area, every property must satisfy the following conditions:
Non-convex properties are allowed as long as the angles between consecutive sides follow rule 3, so the inner angle at a vertex can also be between 360−144=216 and 360−18=342 degrees. See Figure K.1 for an example.

Figure K.1: The property of Sample Input 1 and one way to plant the two trees in it. All the marked angles are at least 18 and at most 144 degrees.
Your property follows these rules. Decide whether you can plant two trees inside the property so that their branches and leaves do not grow beyond its boundary and the branches and leaves of each tree do not grow into the other tree.
The first line contains an integer n (3≤n≤2000), the number of vertices of the polygon that describes your property.
Each of the next n lines describes one vertex and contains two integers x and y (0≤x,y≤107), the x- and y-coordinates of the vertex in millimeters. The vertices are given in clockwise order as they appear on the polygon.
Each side of the polygon is at least 30 meters (30 000 millimeters) long, and the angle between the two sides that meet at a vertex is at least 18 degrees and at most 144 degrees. The polygon does not intersect itself and is closed, that is, the last vertex is connected to the first vertex.
If you can plant the two trees so that no branches grow beyond the boundary of your property or into the other tree, print possible. Otherwise, print impossible.
The input is chosen so that increasing or decreasing the radius of the trees by 1 millimeter does not change whether the two trees can be planted.