sgu Theodore Roosevelt【判断点是否在凸多边形内模板】
来源:互联网 发布:js array item 编辑:程序博客网 时间:2024/05/21 07:13
链接:
http://acm.sgu.ru/problem.php?contest=0&problem=253
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27464#problem/A
253. Theodore Roosevelt
time limit per test: 0.5 sec.
memory limit per test: 65536 KB
memory limit per test: 65536 KB
input: standard
output: standard
output: standard
Danger! Sudden attack on Russia! These are Americans "again", but this time they are serious. Giant aircraft-carrier "Theodore Roosevelt" is entering the Baltic Sea. At one o'clock American aircraft launched from the carrier bombed Petrozavodsk.
At three o'clock we detected the location of "Theodore Roosevelt". In a moment Russian fighters Mig-29 took off into the night air to inflict the crushing strike against the carrier. Using top secret military satellite "Raduga-1" we detected the exact region where the carrier was located - the convex polygon. The fighters launched M rockets and ground forces detected the coordinates of their explosions.
You are an indispensable engineer of Russian military forces, and you were waken up by the phone call at four o'clock. They command you to arrive to headquarters for the most important task - detect whether "Theodore Roosevelt" was destroyed or not! You are given all information: the coordinates of vertices of the region polygon and the coordinates of the explosions.
It was computed that at least K rockets should have hit the detected region to destroy the carrier. Commander ordered you to complete the work till five o'clock, so you must hurry.
At three o'clock we detected the location of "Theodore Roosevelt". In a moment Russian fighters Mig-29 took off into the night air to inflict the crushing strike against the carrier. Using top secret military satellite "Raduga-1" we detected the exact region where the carrier was located - the convex polygon. The fighters launched M rockets and ground forces detected the coordinates of their explosions.
You are an indispensable engineer of Russian military forces, and you were waken up by the phone call at four o'clock. They command you to arrive to headquarters for the most important task - detect whether "Theodore Roosevelt" was destroyed or not! You are given all information: the coordinates of vertices of the region polygon and the coordinates of the explosions.
It was computed that at least K rockets should have hit the detected region to destroy the carrier. Commander ordered you to complete the work till five o'clock, so you must hurry.
Input
The first line of input contains three integers N, M and K (3<=N<=10^5, 0<=K<=M<=10^5). The following N lines contain coordinates of polygon vertices in counter-clockwise order. And then last M lines contain coordinates of rockets explosions. Is is guaranteed that all coordinates are integer numbers not exceeding 10^9 by their absolute value.
Output
Output "YES" (without quotes) if "Theodore Roosevelt" was destroyed, or "NO" (without quotes) in the other case.
Sample test(s)
Input
5 4 2 1 -1 1 2 0 4 -1 2 -1 -1 -2 -1 1 -1 0 1 2 3
Output
YES
[submit]
[forum]
/********************************************************AAccepted2391 KB15 msVisual Studio C++ 20101439 B2013-07-28 09:57:10题意: 给你一个 N 个点的凸多边形 判断 M 个点是否至少有 K 个点在凸多边形内部或边界********************************************************/#include<stdio.h>#include<math.h>const int maxn = 100000+10;struct Point{ double x,y; Point() {} Point(double _x, double _y) { x = _x; y = _y; } Point operator - (const Point & B) const { return Point(x-B.x, y-B.y); }}p[maxn];const double eps = 1e-10;int dcmp(double x){ if(fabs(x) < 0) return 0; else return x < 0 ? -1 : 1;}double Cross(Point A, Point B){ return A.x*B.y - A.y*B.x;}/** 点Point 是否在有 n 个顶点的凸多边形内【含边界】*/bool isPointInConvex(Point *p, int n, Point point){ bool flag = true; p[n] = p[0]; int now = dcmp(Cross(p[0]-point, p[1]-point)); for(int i = 1; i < n; i++) { int next = dcmp(Cross(p[i]-point, p[i+1]-point)); if(next*now < 0) { flag = false; break; } now = next; } return flag;}int main(){ int n,m,k; while(scanf("%d%d%d", &n,&m,&k) != EOF) { for(int i = 0; i < n; i++) scanf("%lf%lf", &p[i].x, &p[i].y); Point point; int sum = 0; while(m--) { scanf("%lf%lf", &point.x, &point.y); if(isPointInConvex(p, n, point)) sum++; } if(sum >= k) printf("YES\n"); else printf("NO\n"); } return 0;}
- sgu Theodore Roosevelt【判断点是否在凸多边形内模板】
- SGU 253. Theodore Roosevelt
- SGU 253. Theodore Roosevelt
- sgu-253 Theodore Roosevelt
- cocos2dx 判断点是否在任意凸多边形内(算法)
- POJ 1264 判断点是否在凸多边形内
- 判断是否是凸多边形,判断点是否在多边形内,点到直线的距离
- Finding Mine判断点在凸多边形内
- 判断一个点在不在凸多边形内(转)
- 计算几何--O(logN) 判断点在凸多边形内
- 判断点在凸多边形内(基于经纬度坐标)
- SGU 124. Broken line 计算几何 判断点是否在多边形内
- SGU 124. Broken line(射线法判断一个点是否在一个多边形内)
- poj 1584 A Round Peg in a Ground Hole(判断凸多边形+圆是否在凸多边形内)
- POJ1584 A Round Peg in a Ground Hole 判断多边形是否为凸多边形,判断凸多边形是否在圆内
- sgu253:Theodore Roosevelt(扫描线)
- poj 1584 A Round Peg in a Ground Hole 判断多边形是否为凸多边形 + 圆心是否在凸多边形内 + 圆是否在凸多边形内部
- POJ 1584 A Round Peg in a Ground Hole(判断凸多边形,判断圆是否在凸多边形内)
- 2013腾讯编程马拉松初赛第〇场(3月20日)小明系列故事——买年货
- Ural 1180. Stone Game
- 写在《逆袭大学——传给IT学子正能量》修改稿提交之时
- Block详解
- php curl抓取远程页面内容的代码分享
- sgu Theodore Roosevelt【判断点是否在凸多边形内模板】
- MyEclipse 8.5 与MyEclipse 6.5代码自动提示设置
- ACM CLUB第四周周赛题解_部分
- 黑马程序员---毕向东老师视频笔记(关于static)
- 深入PHP curl参数的详解
- 突破MySQL视图限制:获取创建视图的SQL语句
- 【C#如何判断字符串是否为空串】
- [Fedora]:Google Chrome安装错误
- 数塔