题目

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
typedef unsigned long long Ull;
#define MM(a,b) memset(a,b,sizeof(a));
const double eps = 1e-10;
const int inf = 0x3f3f3f3f;
const double pi=acos(-1);
const int mod=100000000; struct Point{
double x,y;
//Point(){};
Point(double xx=0,double yy=0):x(xx),y(yy){}
bool read()
{
return ~scanf("%lf%lf", &x, &y);
}
bool operator<(const Point p) const{
if(this->x!=p.x)
return this->x<p.x;
else return this->y<p.y;
}
double dot(Point p)
{
return this->x*p.x+this->y*p.y;
}
double getA()
{
double A=atan2(this->y,this->x);
if(A<-pi/2+eps) A+=2*pi;
return A;
}
Point operator-(Point p)
{
return Point(this->x-p.x,this->y-p.y);
}
}; double det(Point p,Point q)
{
return p.x*q.y-q.x*p.y;
} int dcmp(double x)
{
if(fabs(x)<eps) return 0;
else if(x>0) return 1;
else return -1;
}
Point p[100005],ans[100005];
double ang[100005]; int Convex_hull(Point *p,int n,Point *ans)
{
sort(p+1,p+n+1);
ans[1]=p[1];ans[2]=p[2];
int w=2;
for(int i=3;i<=n;i++)
{
int k=dcmp(det(p[i]-ans[w-1],ans[w]-ans[w-1]));
while(dcmp(det(p[i]-ans[w-1],ans[w]-ans[w-1]))>0&&w>=2)
w--;
ans[++w]=p[i];
}
int cur=w;
ans[++w]=p[n-1];
for(int i=n-2;i>=2;i--)
{
int k=dcmp(det(p[i]-ans[w-1],ans[w]-ans[w-1]));
while(dcmp(det(p[i]-ans[w-1],ans[w]-ans[w-1]))>0&&w>=cur+1)
w--;
ans[++w]=p[i];
}
return w;
} int main()
{
int n;
while(~scanf("%d",&n))
{
for(int i=1;i<=n;i++) p[i].read();
int m=0;
if(n>1) {m=Convex_hull(p,n,ans);}
ans[m+1]=ans[0];
for(int i=1;i<=m;i++)
ang[i]=(ans[i+1]-ans[i]).getA();
Point q[3];
while(q[1].read())
{
q[2].read();
int i=upper_bound(ang+1,ang+m+1,(q[2]-q[1]).getA())-ang;
int j=upper_bound(ang+1,ang+m+1,(q[1]-q[2]).getA())-ang;
if(n>1&&dcmp(det(q[2]-q[1],ans[i]-q[1]))*dcmp(det(q[2]-q[1],ans[j]-q[1]))<0)
printf("BAD\n");
else printf("GOOD\n");
}
}
return 0;
}

  

POJ 1912 凸包的更多相关文章

  1. poj 1873 凸包+枚举

    The Fortified Forest Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6198   Accepted: 1 ...

  2. poj 1113 凸包周长

    Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 33888   Accepted: 11544 Descriptio ...

  3. Poj 2187 凸包模板求解

    Poj 2187 凸包模板求解 传送门 由于整个点数是50000,而求凸包后的点也不会很多,因此直接套凸包之后两重循环即可求解 #include <queue> #include < ...

  4. POJ 1912 A highway and the seven dwarfs (凸包)

    [题目链接] http://poj.org/problem?id=1912 [题目大意] 给出一些点,表示一些屋子,这些屋子共同组成了村庄,现在要建一些高速公路 问是否经过了村庄. [题解] 这些屋子 ...

  5. poj 3348--Cows(凸包求面积)

    链接:http://poj.org/problem?id=3348 Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions:  ...

  6. poj 1228 凸包

    题目链接:http://poj.org/problem?id=1228 #include<cstdio> #include<cstring> #include<cmath ...

  7. poj 2187 凸包加旋转卡壳算法

    题目链接:http://poj.org/problem?id=2187 旋转卡壳算法:http://www.cppblog.com/staryjy/archive/2009/11/19/101412. ...

  8. POJ 3608 凸包间最短距离(旋转卡壳)

    Bridge Across Islands Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11539   Accepted: ...

  9. POJ 1113 凸包模板题

    上模板. #include <cstdio> #include <cstring> #include <iostream> #include <algorit ...

随机推荐

  1. JavaScript中:地址引用的特性,导致静态初始值被修改

    问题分类 JavaScript,值引用,地址引用 问题描述 开发过程中,服务端将静态配置数据从mysql数据库中读取到内存中,方便调用. 在实现流派功能时,需从数据库中读取流派种类数据到内存中,由于其 ...

  2. [转帖]Windows与Linux的命令行命令对比

    Windows与Linux的命令行命令对比 https://www.cnblogs.com/sztom/p/10785140.html * Windows不区分大小写,Linux区分大小写的. sn ...

  3. Linux 下文件句柄数的查询学习

    1. 查看 所有进程的 打开的句柄数 lsof -n|awk '{print $2}'|sort|uniq -c |sort -nr|more 效果为: 2. 查看某一个进程内的 文件信息 lsof ...

  4. Spring中pom文件所需节点

    <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> &l ...

  5. C语言---程序的一般形式、数据类型、常量变量、运算符、表达式、格式化输入输出

    1. 程序的一般形式 (1)注释 ① 分类:单行注释( // ): 注释一行.多行注释( /**/ ): 在这个区间内,都属于多行注释,可以换行. ② 作用:提示代码的作用,提示思路   不写注释的后 ...

  6. 内核中likely和unlikely宏定义

    在内核代码中经常会看到unlikely和likely的踪影.他们实际上是定义在 linux/compiler.h 中的两个宏. #define likely(x)    __builtin_expec ...

  7. redis 无序集合 数据类型

    sadd  emptno 8000 sadd  emptno 8001 sadd  emptno 8002 smembers  emptno 返回集合全部数据 scard  获取集合长度 sismem ...

  8. 编写python爬虫采集彩票网站数据,将数据写入mongodb数据库

    1.准备工作: 1.1安装requests: cmd >> pip install requests 1.2 安装lxml: cmd >>  pip install lxml ...

  9. Json解析报错: Error is : Unescaped control character...的解决方法

    在利用json-framework来实现json解析的过程时,会出现"-JSONValue Failed. Error is : Unescaped control character&qu ...

  10. Linux中配置jdk环境变量出错:bad ELF interpreter: No such file or directory解决方法

    yum install glibc.i686 重新安装,javac成功 如果还有如下类系错误 再继续安装包 error while loading shared libraries: libstdc+ ...