链接:



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. Uncaught SyntaxError: Invalid Unicode escape sequence异常处理

    今天碰到一个问题,页面报错:Uncaught SyntaxError: Invalid Unicode escape sequence ,{index:'operate',name:'operate' ...

  2. python2代码升级到python3工具

    python模块lib2to3(py2转py3自动化工具) Usage: 2to3 [options] file|dir ... Options: -h, --help show this help ...

  3. ElasticSearch refresh和flush的理解

    在索引数据的时候,要保证被索引的文档能够立即被搜索到,就要涉及到_refresh 和_flush这两个方法. 1.fresh 当索引一个文档,文档先是被存储在内存里面,默认1秒后,会进入文件系统缓存, ...

  4. 容量测试之tcpcopy引流模式

    tcpcopy 给用户提供了很多命令参数来修改引流的模式和设置,详细可以查阅手册.在这里把几种常见的引流方式做个归纳小结,以tcpcopy传统架构使用命令举例. 1.分布式引流 用法:Tcpcopy可 ...

  5. 经典的排序算法java实现版

    /** * * @author yuzhiping * @version 1.0 * 功能说明:计算机领域经典的算法 * */ public class sortAlgorithm<T exte ...

  6. jquery ui widget 源代码分析

    jquery ui 的全部组件都是基于一个简单,可重用的widget. 这个widget是jquery ui的核心部分,有用它能实现一致的API.创建有状态的插件,而无需关心插件的内部转换. $.wi ...

  7. Nginx 限制单个IP的并发连接数及对每个连接速度(限速)

    使用Nginx限制单个IP的并发连接数能够减少一些采集程序或者DDOS的攻击. 再lnmp的nginx配置中已经添加了部分代码,但是是注释掉的,可以编辑/usr/local/nginx/conf/ng ...

  8. iOS语言本地化,中文显示

    尽管一直相信xcode肯定提供有语言本地化的设置地方,可是一直也没凑着去改.非常多的汉化,还是使用代码去控制:比方navagition的return使用代码改动为"返回"! 近期在 ...

  9. Redis 数据恢复方法,redis-port 工具将自建 redis 的 rdb文件同步到云数据库

    1. Redis 恢复的机制 如果只配置 AOF ,重启时加载 AOF 文件恢复数据: 如果同时配置了 RDB 和 AOF ,启动是只加载 AOF 文件恢复数据: 如果只配置 RDB,启动是将加载 d ...

  10. android应用中插入admob广告

    Step One  登陆admob,注册用户 直接登陆http://www.admob.com/,用google的账号登陆 Step Two 登陆admob后,在站点和应用程序选项中 选择并添加and ...