#include #include #include #include // #include // #include // #include #define oo 1000000000 #define PI 3.14159265389793 #define EPS 1e-9 #define DBG(x) x #define PRINT(x) cout << (#x) << " = " << x << endl #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) int main(){ ifstream in("video.in"); int altx, alty,x,y,oben,unten,links,rechts,nV; int startx, starty; int z=0; in >> nV; while(nV>0 && !in.eof() ) { z++; oben=oo; unten=-oo; links=-oo; rechts=oo; in >> x; in >> y; startx=x; starty = y; for(int i=0; i< nV-1; i++) { altx=x; alty=y; in >> x >> y; if( x-altx == 0) { // horizontal if( y > alty ) // nach oben links=MAX(links,x); else // nach unten rechts=MIN(rechts,x); } else { // vertikal if( x > altx ) // nach rechts oben=MIN(oben,y); else unten=MAX(unten,y); } } altx=x; alty=y; x=startx; y=starty; if( x-altx == 0) { // horizontal gleich if( y > alty ) // nach oben links=MAX(links,x); else // nach unten rechts=MIN(rechts,x); } else { // vertikal gleich if( x > altx ) // nach rechts oben=MIN(oben,y); else unten=MAX(unten,y); } cout << "Floor #" << z << endl; if( oben >= unten && links <= rechts) cout << "Surveillance is possible.\n\n"; else cout << "Surveillance is impossible.\n\n"; in >> nV; } return 0; }