链接:



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. leetcode题解:Valid Parentheses(栈的应用-括号匹配)

    题目: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the ...

  2. android 中怎样获取IMEI号

    1)在Telephony Framework内部.能够直接使用GSMPhone或GeminiPhone提供的接口. KK之前的版本号: IMEI(International Mobile Equipm ...

  3. Java 实例

    Java 实例 本章节我们将为大家介绍 Java 常用的实例,通过实例学习我们可以更快的掌握 Java 的应用. Java 环境设置实例 Java 实例 – 如何编译一个Java 文件? Java 实 ...

  4. Linux网络编程中tcp_server和tcp_client函数的封装

    本文的主要目的是将server套接字和client套接字的获取,做一个简易的封装,使用C语言完成.   tcp_server   服务器端fd的获取主要分为以下几步: 1.创建socket,这一步仅仅 ...

  5. jquery技术揭秘静态工具函数源码重构

    1.调用页面 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UT ...

  6. javascript 模块引擎 (手写草稿)

    1.试题: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  7. HDU1789 Doing Homework again 【贪心】

    Doing Homework again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  8. 数据库表设计时一对一关系存在的必要性 数据库一对一、一对多、多对多设计 面试逻辑题3.31 sql server 查询某个表被哪些存储过程调用 DataTable根据字段去重 .Net Core Cors中间件解析 分析MySQL中哪些情况下数据库索引会失效

    数据库表设计时一对一关系存在的必要性 2017年07月24日 10:01:07 阅读数:694 在表设计过程中,我无意中觉得一对一关系觉得好没道理,直接放到一张表中不就可以了吗?真是说,网上信息什么都 ...

  9. [C/C++标准库]_[0基础]_[怎样实现std::string自己的Format(sprintf)函数]

    场景: 1.  C语言有自己的sprintf函数,可是这个函数有个缺点,就是不知道须要创建多大的buffer, 这时候能够使用snprintf函数来计算大小,仅仅要參数 buffer为NULL, co ...

  10. ssh隧道远程连接mysql

    有时候比如一些云主机,没有开放3306端口,这里可以用ssh隧道来连接数据库,更加安全 注意点: 1.本地ssh可以登录远程服务器,(密码或者秘钥) 2.远程数据库需要赋权限给隧道端的ip 命令: s ...