计算几何-Graham法-凸包
This article is made by Jason-Cow.
Welcome to reprint.
But please post the article's address.
关键一句话
Cross(A[m-1]-R[i],A[m]-R[i])<=0)m--
附加,极角排序,课上讲~~
D O;
bl acomp(D A,D B){
db x=Cross(A-O,B-O);
if(x>)return ;if(x<)return ;
return Dis(O,A)<Dis(O,B);
} int Graham(D*R,int n,D*A){
for(int i=;i<=n;i++)
if(R[i].y<R[].y||(R[i].y==R[].y&&R[i].x<R[].x))swap(R[i],R[]);
O=R[],sort(R+,R+n+,acomp);
int m=;A[++m]=R[],A[++m]=R[];
for(int i=;i<=n;i++){
while(m> && Cross(A[m-]-R[i],A[m]-R[i])<=)m--;
A[++m]=R[i];
}
return m;
}
学了Andrew后,觉得Graham好丑,而且常数还大
唯一的好处是好写,其实差不多
计算几何-Graham法-凸包的更多相关文章
- 计算几何-Andrew法-凸包
This article is made by Jason-Cow.Welcome to reprint.But please post the article's address. 利用一下叉积和栈 ...
- poj 1113:Wall(计算几何,求凸包周长)
Wall Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 28462 Accepted: 9498 Description ...
- poj 3348:Cows(计算几何,求凸包面积)
Cows Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 6199 Accepted: 2822 Description ...
- hdu 1392:Surround the Trees(计算几何,求凸包周长)
Surround the Trees Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- poj 2187:Beauty Contest(计算几何,求凸包,最远点对)
Beauty Contest Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 26180 Accepted: 8081 D ...
- Graham Scan凸包算法
获得凸包的算法可以算是计算几何中最基础的算法之一了.寻找凸包的算法有很多种,Graham Scan算法是一种十分简单高效的二维凸包算法,能够在O(nlogn)的时间内找到凸包. 首先介绍一下二维向量的 ...
- hdu 1348:Wall(计算几何,求凸包周长)
Wall Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- 【BZOJ-1670】Building the Moat护城河的挖掘 Graham扫描法 + 凸包
1670: [Usaco2006 Oct]Building the Moat护城河的挖掘 Time Limit: 3 Sec Memory Limit: 64 MBSubmit: 464 Solv ...
- POJ 1113 Wall(Graham求凸包周长)
题目链接 题意 : 求凸包周长+一个完整的圆周长. 因为走一圈,经过拐点时,所形成的扇形的内角和是360度,故一个完整的圆. 思路 : 求出凸包来,然后加上圆的周长 #include <stdi ...
随机推荐
- Python获取时间范围
import datetime def dateRange(beginDate, endDate): dates = [] dt = datetime.datetime.strptime(beginD ...
- Doing Homework HDU - 1074 状态压缩
#include<iostream> #include<cstring> #include<cstdio> #include<string> #incl ...
- .net Core 配置Centos守护进程Supervisor
声明: 博客引用来源:https://blog.csdn.net/qq_37997978/article/details/83311177建议看原版,更为详细 介绍: Supervisor( http ...
- Docker的安装和操作(虚拟机+linux系统)
1.简介 Docker是一个开源的应用容器引擎:是一个轻量级容器技术: Docker支持将软件编译成一个镜像:然后在镜像中各种软件做好配置,将镜像发布出去,其他使用者可以直接使用这个镜像: 运行中的这 ...
- 3ds Max File Format (Part 2: The first inner structures; DllDirectory, ClassDirectory3)
Now that we understand the outer structure of the file, it's time to look closer to what's inside. T ...
- IIS之虚拟目录
在站点物理路径下如果有多种文件夹,储存量较大主目录可能空间有限,因此必须放在其他分区上,而访问上述文件夹逻辑上还归属于网站,这种归属于网络之下的目录被称为虚拟目录. 右键添加虚拟目录 选择结束点击确定 ...
- 牛客多校第七场H Pair 数位dp理解
Pair 题意 给出A B C,问x取值[1,A]和y取值[1,B]存在多少组pair<x,y>满足以下最小一种条件,\(x \& y >c\),\(x\) xor \(y& ...
- 【Python】天天向上的力量
每天进步一点点会有什么不同呢? Q1:每天进步千分之一或退步千分之一会怎么样? #DayDayUp,每天进步一千分之一 print("基础为1") dayup=pow(1.001, ...
- HTML列表,表格与媒体元素
一.无序列表 <ul> <li>无序列表</li> <li>有序列表</li> <li>自定义列表</li> < ...
- linux中的oracle数据库
安装orcal http://www.cnblogs.com/nucdy/p/5603998.html 搭建Linux操作系统+Oracle数据库的环境 https://blog.csdn.net/p ...