POJ 1474 Video Surveillance(半平面交)
2013-10-15 16:54
295 查看
题目链接
2Y,模版抄错了一点。
2Y,模版抄错了一点。
#include <cstdio> #include <cstring> #include <string> #include <cmath> #include <algorithm> using namespace std; #define eps 1e-8 #define N 2001 struct point { double x,y; }p ,pre ,temp ; double a,b,c; int n,m; void getline(point x,point y) { a = y.y - x.y; b = x.x - y.x; c = y.x * x.y - x.x * y.y; } point intersect(point x,point y) { double u = fabs(a*x.x + b*x.y + c); double v = fabs(a*y.x + b*y.y + c); point ans; ans.x = (x.x*v+y.x*u)/(u+v); ans.y = (x.y*v+y.y*u)/(u+v); return ans; } void cut() { int num = 0,i; for(i = 1;i <= m;i ++) { if(a*p[i].x + b*p[i].y + c > -eps) { temp[++num] = p[i]; } else { if(a*p[i-1].x + b*p[i-1].y + c > eps) temp[++num] = intersect(p[i],p[i-1]); if(a*p[i+1].x + b*p[i+1].y + c > eps) temp[++num] = intersect(p[i],p[i+1]); } } for(i = 1;i <= num;i ++) p[i] = temp[i]; p[0] = p[num]; p[num+1] = p[1]; m = num; } void fun() { int i; m = n; for(i = 1;i <= n;i ++) { getline(pre[i],pre[i+1]); cut(); } } int main() { int i,cas = 1; while(scanf("%d",&n)!=EOF) { if(!n) break; for(i = 1;i <= n;i ++) { scanf("%lf%lf",&pre[i].x,&pre[i].y); p[i] = pre[i]; } pre[n+1] = pre[1]; p[n+1] = p[1]; p[0] = p ; fun(); printf("Floor #%d\n",cas ++); if(m) printf("Surveillance is possible.\n"); else printf("Surveillance is impossible.\n"); printf("\n"); } return 0; }
相关文章推荐
- POJ 1474 Video Surveillance 半平面交求多边形是否有核
- POJ 1474 Video Surveillance(半平面交)
- POJ3335 POJ3130 POJ1474 [半平面交]
- poj 1474 Video Surveillance(半平面交)
- POJ 1474 Video Surveillance 半平面交
- poj 1474 Video Surveillance (半平面交)
- poj 1474 Video Surveillance 半平面交
- POJ 1474 Video Surveillance 半平面交求多边形内核存在性
- BSOJ1850:POJ1474摄像头 计算几何 半平面交
- poj1474 Video Surveillance【半平面交】
- poj 1474 半平面交求多边形的核
- POJ 1474 多边形的核(半平面交)
- POJ 1474 ZOJ 1248 HDU 1469 Video Surveillance 半平面交
- 半平面交入门 poj 3335 poj 1474 poj 1279 半平面交模板
- POJ 1474 半平面交
- poj 3335 && poj 3130 && poj 2451 && poj 1474(n(logn)求解半平面交)
- poj 1474 Video Surveillance (半平面交)
- poj 1474 Video Surveillance 【半平面交】
- POJ 1474 半平面交
- [poj 1474]Video Surveillance[半平面交][多边形的核]