链接:



253. Theodore Roosevelt

time limit per test: 0.5 sec.

memory limit per test: 65536 KB
input: 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.


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

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【判断点是否在凸多边形内模板】的更多相关文章

  1. POJ1584 判断多边形是否为凸多边形,并判断点到直线的距离

    求点到直线的距离: double dis(point p1,point p2){   if(fabs(p1.x-p2.x)<exp)//相等的  {    return fabs(p2.x-pe ...

  2. hdu 2108:Shape of HDU(计算几何,判断多边形是否是凸多边形,水题)

    Shape of HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  3. hdu 2108 Shape of HDU【判断多边形是否是凸多边形模板】

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=2108 http://acm.hust.edu.cn/vjudge/contest/view.action ...

  4. SGU 253 Theodore Roosevelt 快速判断点是否在凸包内

    http://acm.sgu.ru/problem.php?contest=0&problem=253 题意简单易懂...给你n个点的凸包(经测试已经是极角序)...判断m个点是否在凸包内.. ...

  5. Broken line - SGU 124(判断点与多边形的关系)

    题目大意:RT 分析:构造一条射线,如果穿越偶数条边,那么就在多边形外面,如果穿越奇数条边,那么就在多边形里面. 代码如下: ===================================== ...

  6. 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 ...

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

  8. 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 ...

  9. UVALive 7281 Saint John Festival (凸包+O(logn)判断点在凸多边形内)

    Saint John Festival 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/J Description Porto's ...

随机推荐

  1. tensorflow BasicRNNCell调试

    运行以下代码,进入~/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/rnn.py和~/anaconda3/lib/python ...

  2. 通过Linux定时任务实现定时轮询数据库及发送Http请求

    通过Linux定时任务实现定时轮询数据库及发送Http请求 概述 有时需要临时增加一个定时任务(需要根据数据库查询结果然后发送HTTP请求),如果在项目中额外增加(Java+Spring+Quartz ...

  3. shell中set命令

    set命令作用主要是显示系统中已经存在的shell变量,以及设置shell变量的新变量值.set命令不能够定义新的shell变量.如果要定义新的变量,可以使用declare命令以变量名=值的格式进行定 ...

  4. 关于Docker&kubernetes的一些问题

    本文是我自己在学习docker以及kubernetes的过程中遇到的一些问题,以及同事在听过培训之后一些问题,事后我自己去网上找些资料以及问一些资深大牛,我在此做一个归纳总结,将这些问题的解答做一个分 ...

  5. HDU 2767 Proving Equivalences (强联通)

    pid=2767">http://acm.hdu.edu.cn/showproblem.php?pid=2767 Proving Equivalences Time Limit: 40 ...

  6. MySQL5.7 基于二进制包的安装

    1.MySQL5.7安装注意事项 1.在MySQL5.7中mysql_install_db已经不再推荐使用,建议改成mysqld-initialize 完成实力初始化.(mysql_install_d ...

  7. UUID(即GUID)

    UUID(GUID)是Cocoa Touch提供的一种生成唯一标识的机制.类型为CFUUIDRef的对象可以代表UUID,UUID是基于当前时间.计数器和硬件标识(通常是以太网卡的MAC地址)等数据计 ...

  8. Cocos2d-x教程(35)-三维拾取Ray-AABB碰撞检測算法

    欢迎增加Cocos2d-x 交流群:193411763 转载时请注明原文出处 :http://blog.csdn.net/u012945598/article/details/39927911 --- ...

  9. linux下 apache启动、停止、重启命令

    假设你的apahce安装目录为/usr/local/apache2,这些方法适合任何情况 apahce启动命令:推荐/usr/local/apache2/bin/apachectl start apa ...

  10. SpringSecurity学习二----------实现自定义登录界面

    © 版权声明:本文为博主原创文章,转载请注明出处 1.项目结构 2.pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0& ...