链接:



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. 2017.8.9在虚拟机中安装linux系统

    0 安装前提 已经安装好VM,并且配置好,具体过程参看随笔:2017.8.5 VMware的介绍与安装 相关随笔:2017.8.5 Linux达人养成计划 I 需要知道的概念:VMWare,虚拟机,真 ...

  2. 2017.3.31 spring mvc教程(七)多视图控制器

    学习的博客:http://elf8848.iteye.com/blog/875830/ 我项目中所用的版本:4.2.0.博客的时间比较早,11年的,学习的是Spring3 MVC.不知道版本上有没有变 ...

  3. [GraphQL] Reuse Query Fields with GraphQL Fragments

    A GraphQL fragment encapsulates a collection of fields that can be included in queries. In this vide ...

  4. Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.

    1.Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'. 原因解析: gradle ...

  5. mui 本地打包

    第一步:下载HBuilder离线打包Android版SDK 网址:http://ask.dcloud.net.cn/article/38 第二步:导入项目 启动带ADT的eclipse程序,菜单中选择 ...

  6. rabbit mq 安装

    不知道为什么上不去erlang的官网,所以只能到中文社区来下载了. http://www.cnerlang.com/ 我下载的是下面这个版本 http://download.cnerlang.com/ ...

  7. Hbase笔记3 shell命令

    http://www.jb51.net/article/31172.htm 这个文章写得挺好 1.HBase的shell就和我们用Mysql的终端是一个意思,比如我们安装好Mysql,配置好了环境变量 ...

  8. 测试代码覆盖率工具学习(Android Emma)

    博客分类: 工具分享 eclipseeclemmaemmatestng       关于eclemma的历史和怎么安装,请参考http://www.ibm.com/developerworks/cn/ ...

  9. C++ 输出100—999中所有的水仙花数

    输出100-999中所有的水仙花数,若3位数xyz满足 , 则xyz为水仙花数,例如 , 因此153是水仙花数. #include <iostream> using namespace s ...

  10. the reactor pattern and java nio

    在<java NIO>作者PPT<How to Build a Scalable Multiplexed Server With NIO> 和 Doug Lea <Sca ...