凸包(旋转卡壳求最远点)
来源:互联网 发布:聚合数据 编辑:程序博客网 时间:2024/04/29 22:16
计算几何之凸包(一) {卷包裹算法}
http://www.cnblogs.com/Booble/archive/2011/02/28/1967179.html#3229390
计算几何之凸包(二) {更高效的算法}
http://www.cnblogs.com/Booble/archive/2011/03/10/1980089.html计算几何之凸包(三) {旋转卡壳初步}
http://www.cnblogs.com/Booble/archive/2011/04/03/2004865.html快速凸包
QuickHull#include <iostream>#include <math.h>#define maxn 100000#define zero 1e-12#define sgn(x) (fabs(x)<zero?0:(x>0?1:-1))#define cross(a,b,c) ((b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x))#define cmp(a,b) (a.x<b.x || sgn(a.x-b.x)==0 && a.y<b.y)using namespace std;struct point{ double x,y;}p[maxn];double s[maxn];void hull(int l,int r,point a,point b){ int x=l,i=l-1,j=r+1,k; for (k=l;k<=r;k++){ double temp=sgn(s[x]-s[k]); if (temp<0 || temp==0 && cmp(p[x],p[k])) x=k; } point y=p[x]; for (k=l;k<=r;k++){ s[++i]=cross(p[k],a,y); if (sgn(s[i])>0) swap(p[i],p[k]); else i--; } for (k=r;k>=l;k--){ s[--j]=cross(p[k],y,b); if (sgn(s[j])>0) swap(p[j],p[k]); else j++; } if (l<=i) hull(l,i,a,y); printf("%.4lf %.4lf\n",y.x,y.y); if (j<=r) hull(j,r,y,b);}int main(){ freopen("CH2D.in","r",stdin); freopen("CH2D1.out","w",stdout); int n,i,x=0; scanf("%d",&n); for (i=1;i<=n;i++){ scanf("%lf %lf",&p[i].x,&p[i].y); if (x==0 || cmp(p[i],p[x])) x=i; } swap(p[1],p[x]); printf("%.4lf %.4lf\n",p[1].x,p[1].y); hull(2,n,p[1],p[1]); return 0;}
0 0
- 凸包(旋转卡壳求最远点)
- POJ 2187 Beauty Contest (求最远点对,凸包+旋转卡壳)
- Poj2187(最远点对距离)凸包+旋转卡壳
- HDU1007-Quoit Design(求最近点对,求最远点对(凸包+旋转卡壳))
- poj 2187 求平面最远点对 快速凸包 旋转卡壳
- 【凸包】poj 2187 Beauty Contest (旋转卡壳求平面最远点对)
- POJ-2178 Beauty Contest 凸包+旋转卡壳求最远点对
- 旋转卡壳 求最远点对
- poj2187 凸包+graham+旋转卡壳+最远点对
- [计算几何][凸包][旋转卡壳] 最远距离点对
- poj2187 凸包上的最远点对的距离(凸包+旋转卡壳)
- poj 2187 Beauty Contest 计算几何(凸包+旋转卡壳法)/最远点对
- POJ2187 Beauty Contest(最远点对,凸包+旋转卡壳)
- POJ 2187 Beauty Contest(凸包_旋转卡壳之最远点对)
- POJ2187-Beauty Contest- 最远点对问题(凸包+旋转卡壳)
- POJ2187(旋转卡壳求平面最远点对)
- poj 2187 旋转卡壳求最远点对的平方
- [Poj2187]Beauty Contest (旋转卡壳求最远点对)
- poj3233Matrix Power Series 矩阵快速幂
- 【HAOI2006】【BZOJ2428】均分数据
- easymock,cactus测试controller
- Android数据库--创建表和LitePal的基本用法
- CC2530发射功率及其设置
- 凸包(旋转卡壳求最远点)
- latex教程
- HDU 1520 & POJ 2342 Anniversary party(树形DP入门题)
- Spring BeanFactory getBean 源码剖析
- 条款 04 make sure that objects are initialized before they're used
- linux下 mysql 操作
- 自动装箱问题以及字符创的==问题
- Linux系统mysql密码和远程访问设置
- 前端最重要的工作——HTML构架