A friend of yours has taken the job of security officer at the Star-Buy Company, a famous depart- ment store. One of his tasks is to install a video surveillance system to guarantee the security of the customers (and the security of the merchandise of course) on all of the store’s countless floors. As the company has only a limited budget, there will be only one camera on every floor. But these cameras may turn around to look in every direction.
The first problem is to choose where to install the camera for every floor. The only requirement is that every part of the room must be visible from there. In the following figure the left floor can be completely surveyed from the position indicated by a dot, while for the right floor, there is no such position, the given position failing to see the lower left part of the floor.
Before trying to install the cameras, your friend first wants to know whether there is indeed a suitable position for them. He therefore asks you to write a program that, given a ground plan, de- termines whether there is a position from which the whole floor is visible. All floor ground plans form rectangular polygons, whose edges do not intersect each other and touch each other only at the corners.
Input
The input contains several floor descriptions. Every description starts with the number $n$ of vertices that bound the floor $(4 \le n \le 100)$. The next $n$ lines contain two integers each, the $x$ and $y$ coordinates for the $n$ vertices, given in clockwise order. All vertices will be distinct and at corners of the polygon. Thus the edges alternate between horizontal and vertical.
A zero value for $n$ indicates the end of the input.
Output
For every test case first output a line with the number of the floor, as shown in the sample output. Then print a line stating “Surveillance is possible.” if there exists a position from which the entire floor can be observed, or print “Surveillance is impossible.” if there is no such position.
classPoint { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} inlinevoidinput(){ scanf("%lf%lf", &x, &y); } booloperator<(const Point &a) const { return (!dcmp(x - a.x))? dcmp(y - a.y) < 0: x < a.x; } booloperator==(const Point &a) const { return dcmp(x - a.x) == 0 && dcmp(y - a.y) == 0; } db dis2(const Point a){ returnpow(x - a.x, 2) + pow(y - a.y, 2); } db dis(const Point a){ returnsqrt(dis2(a)); }
db dis2(){ return x * x + y * y; } db dis(){ returnsqrt(dis2()); } Point operator+(const Point a) { return Point(x + a.x, y + a.y); } Point operator-(const Point a) { return Point(x - a.x, y - a.y); } Point operator*(double p) { return Point(x * p, y * p); } Point operator/(double p) { return Point(x / p, y / p); } db cross(const Point a){ return x * a.y - y * a.x; } }; typedef Point Vector;