Poj Solution 1474

http://poj.org/problem?id=1474

#include<iostream>
using namespace std;
int xmin,ymin,xmax,ymax,n;
int main()
{int i,xn,yn,xp,yp,dx,dy,c_n=0;
while(1)
{cin>>n;
if(!n)break;
xmin=-32000;ymax=32000;
xmax=-xmin;ymin=-ymax;
cin>>xp>>yp;
dx=xp;dy=yp;
for(i=0;i<n;i++)
{if(i<n-1)cin>>xn>>yn;else {xn=dx;yn=dy;}
if(yn==yp){if(xn>xp){if(yp<ymax)ymax=yn;}
            else if(yp>ymin)ymin=yn;
            }
else {if(yn>yp){if(xn>xmin)xmin=xn;}
            else if(xn<xmax)xmax=xn;
            }
xp=xn;yp=yn;
}
cout<<"Floor #"<<++c_n<<endl;
if(xmin<=xmax&&ymin<=ymax)cout<<"Surveillance is possible."<<endl<<endl;
else cout<<"Surveillance is impossible."<<endl<<endl;
}
return 0;
}
											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *