sgu Theodore Roosevelt【判断点是否在凸多边形内模板】
链接:
253. Theodore Roosevelt
memory limit per test: 65536 KB
output: standard
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
that all coordinates are integer numbers not exceeding 10^9 by their absolute value.
Output
Sample test(s)
Input
| Author: | Dmitry Filippov (DEF) |
| Resource: | Petrozavodsk Summer Training Sessions 2004 |
| Date: | August 25, 2004 |
/********************************************************
A Accepted 2391 KB 15 ms Visual Studio C++ 2010 1439 B 2013-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【判断点是否在凸多边形内模板】的更多相关文章
- POJ1584 判断多边形是否为凸多边形,并判断点到直线的距离
求点到直线的距离: double dis(point p1,point p2){ if(fabs(p1.x-p2.x)<exp)//相等的 { return fabs(p2.x-pe ...
- hdu 2108:Shape of HDU(计算几何,判断多边形是否是凸多边形,水题)
Shape of HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- hdu 2108 Shape of HDU【判断多边形是否是凸多边形模板】
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2108 http://acm.hust.edu.cn/vjudge/contest/view.action ...
- SGU 253 Theodore Roosevelt 快速判断点是否在凸包内
http://acm.sgu.ru/problem.php?contest=0&problem=253 题意简单易懂...给你n个点的凸包(经测试已经是极角序)...判断m个点是否在凸包内.. ...
- Broken line - SGU 124(判断点与多边形的关系)
题目大意:RT 分析:构造一条射线,如果穿越偶数条边,那么就在多边形外面,如果穿越奇数条边,那么就在多边形里面. 代码如下: ===================================== ...
- POJ 1518 A Round Peg in a Ground Hole【计算几何=_=你值得一虐】
链接: http://poj.org/problem?id=1584 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...
- POJ 1584 A Round Peg in a Ground Hole【计算几何=_=你值得一虐】
链接: http://poj.org/problem?id=1584 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...
- POJ 1584 A Round Peg in a Ground Hole(判断凸多边形,点到线段距离,点在多边形内)
A Round Peg in a Ground Hole Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4438 Acc ...
- UVALive 7281 Saint John Festival (凸包+O(logn)判断点在凸多边形内)
Saint John Festival 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/J Description Porto's ...
随机推荐
- Win7旗舰版+IIS7没有错误提示怎么办
在IIS Manger中将ASP的调试属性修改默认值,启用服务端调试和客户端调试都改为True,重启后生效.
- Win7删除虚拟机新建的用户怎么恢复
11月3日 VMware Workstation 7 Installed in Windows 7 AutoLogon Problem 安装VMware Workstation 7 在Windows ...
- WebView简单使用
public class MainActivity extends Activity { WebView webView; @Override protected void onCreate(Bund ...
- PHP计算字符串长度函数
//计算字符串长度 function strlen_utf8($str) { $i = 0; $count = 0; $len = strlen ($str); while ($i < $len ...
- eclispe查看jdk源码后特别卡顿导致未响应解决
第一步:Eclipse -> Preferences -> General -> Startup and Shutdown.不要勾选 RSE UI. 第二步:Eclipse -> ...
- h5+ 管理设备信息
Device模块管理设备信息,用于获取手机设备的相关信息,如IMEI.IMSI.型号.厂商等.通过plus.device获取设备信息管理对象. 1.属性 1.1.imei: 设备的国际移动设备身份码, ...
- Oracle 字符串不为空条件
Oracle 中,空字符串存入到Oracle中会自动转换为NULL,另外VARCHAR2把空串等同于null处理. SQL from dual where null=null; 没有查到记录 SQL ...
- Iterative (non-recursive) Merge Sort
An iterative way of writing merge sort: #include <iostream> using namespace std; void merge(in ...
- html及css
html设置网页的结构内容,css设置样式,要记的标签很多,要学好无非是多练,然后看别人怎样写的代码,对比自己的,这样能更好地理解. 关于浮动,既然所有浮动必须要清除,那在设置浮动的同时,就先把清除浮 ...
- iOS SDWebImage加载大图导致内存崩溃解决方案
static BOOL SDImageCacheOldShouldDecompressImages = YES; static BOOL SDImagedownloderOldShouldDecomp ...