No Smoking
Time limit3sMemory limit128 MB
Given up to 200 disjoint rectangles in a town rectangle, decide whether some point in the town lies at distance at least D minus 0.1 from every building.
- Level
Hard8 of 10
- Topics
- Geometry, Union-find, Graph, Implementation
- Solved
- No attempts yet
Problem
When you travel abroad, you must obey the local laws of every country you visit. In some countries the law forbids smoking anywhere closer than a given distance from any building. This raises a practical question: is there any place in a town where you may legally smoke at all?
Luckily, the town we consider is laid out in an orderly way, which makes the question easier to answer. The town boundary is an axis-parallel rectangle , and the buildings are pairwise-disjoint axis-parallel rectangles that lie inside . Because patrols are not equipped with precision instruments, you may smoke at any spot within the town — the boundary of is allowed — whose distance to the nearest building is at least meters and centimeters, that is, at least meters.
Input
The input contains several towns. Each town is described by several lines.
The first line contains four integers , , , and separated by spaces.
- () is the minimum distance from the buildings at which smoking is legal.
- and () are the dimensions of the town, which covers the rectangle with corners , , , and .
- () is the number of buildings.
Each of the following lines contains four integers , , , (, ), giving the corners , , , and of one building. Within a town the buildings are pairwise disjoint.
The last town is followed by a line containing four zeros, which does not describe a town.
Output
For each town, output a single line.
Print Smoking permitted! if there is at least one spot inside the town — the boundary of is allowed — whose distance to every building is at least meters. Otherwise print Smoking not permitted!.
To keep the answer unambiguous, every town is guaranteed to satisfy exactly one of the following: either there is a spot whose distance to every building is at least meters, or every spot in the town is closer than meters to some building.