Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
想到以前刚学半平面交调了一天的代码的我为什么要写半平面交啊 #include<cstdio> #include<algorithm> #define maxn 105 #define inf 0x3f3f3f3f using namespace std; int n,x[maxn],y[maxn],mnx,mxx,mny,mxy; int main(){ int cas = 0; while(~scanf("%d",&n) && n){ for(int i=0;i<n;i++) scanf("%d%d",&x[i],&y[i]); mnx = mny = -inf; mxx = mxy = inf; for(int i=0;i<n;i++){ int v = (i+1)%n; if(x[i] == x[v]){ if(y[i] > y[v]) mxx = min(mxx , x[i]); else mnx = max(mnx , x[i]); } else{ if(x[i] < x[v]) mxy = min(mxy , y[i]); else mny = max(mny , y[i]); } } printf("Floor #%d\n",++cas); if(mnx > mxx || mny > mxy) puts("Surveillance is impossible."); else puts("Surveillance is possible."); putchar('\n'); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator