Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

想到以前刚学半平面交调了一天的代码的我

Posted by 2422 at 2020-06-16 14:38:31 on Problem 1474
为什么要写半平面交啊
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator