POJ 1474 Video Surveillance 半平面交求多边形是否有核


裸的半平面交求多边形是否有核.

多边形的核: 在多边形核上的点可以看到多边形的所有顶点,凸多边形的核显然就是多边形本身.

多边形的核是一个凸包,对多边形的所有边都做向着多边形的半平面交在判断一下是否构成凸包就可以了

一样的题目还有POJ3335


Video Surveillance
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 3438   Accepted: 1523

Description

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. 
POJ 1474 Video Surveillance 半平面交求多边形是否有核_第1张图片

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 <= n <= 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. 

Print a blank line after each test case.

Sample Input

4
0 0
0 1
1 1
1 0
8
0 0
0 2
1 2
1 1
2 1
2 2
3 2
3 0
0

Sample Output

Floor #1
Surveillance is possible.

Floor #2
Surveillance is impossible.

Source

Southwestern European Regional Contest 1997


/* ***********************************************
Author        :CKboss
Created Time  :2015年04月09日 星期四 19时43分00秒
File Name     :POJ1474.cpp
************************************************ */

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;

#define mp make_pair
#define pb push_back

const double eps = 1e-8;
const double pi = acos(-1.0);
const double inf = 1e20;
const int maxp = 111;

int dcmp(double d) { if(fabs(d)b left
	halfplane(point _a,point _b){ a=_a; b=_b;}
	halfplane(line v) { a=v.a; b=v.b; }
	void calcangle() { angle=atan2(b.y-a.y,b.x-a.x); }
	bool operator<(const halfplane &b) const { return angle0))
				hp[m-1]=hp[i];
		}
		n=m;
	}
	bool halfplaneinsert()
	{
		int i;
		for(int i=0;i=ed) return false;
		return true;
	}
};

int n;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

	int cas=1;
	while(scanf("%d",&n)&&n)
	{
		vector vp;
		for(int i=0;i



你可能感兴趣的:(计算几何)