博客
关于我
poj 2187 Beauty Contest(凸包求解多节点的之间的最大距离)
阅读量:418 次
发布时间:2019-03-06

本文共 1125 字,大约阅读时间需要 3 分钟。

1 /*  poj 2187 Beauty Contest 2     凸包:寻找每两点之间距离的最大值 3     这个最大值一定是在凸包的边缘上的!   4      5     求凸包的算法: Andrew算法!  6 */ 7 #include
8 #include
9 #include
10 #include
11 using namespace std;12 13 struct Point{14 Point(){}15 Point(int x, int y){16 this->x=x;17 this->y=y;18 }19 int x, y;20 21 static int cross(Point a, Point b){22 return a.x*b.y - a.y*b.x;23 }24 25 static int dist(Point a, Point b){26 return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y);27 }28 29 Point operator -(Point tmp){30 return Point(x-tmp.x, y-tmp.y);31 }32 };33 34 bool cmp(Point a, Point b){35 if(a.x==b.x)36 return a.y
1 && Point::cross(p[ch[m-1]]-p[ch[m-2]], p[i]-p[ch[m-2]])<=0) m--;54 ch[m++]=i;55 }56 //为啥求上凸包的时候,坐标的从n-2开始:因为n-1点一定是在下凸包中的(因为它的横坐标最大,必然是包含其他节点的) 57 int k=m;58 for(i=n-2; i>=0; --i){59 while(m>k && Point::cross(p[ch[m-1]]-p[ch[m-2]], p[i]-p[ch[m-2]])<=0) m--;60 ch[m++]=i;61 }62 --m;63 int maxD=-1, j, d;64 for(i=0; i

 

转载地址:http://orhuz.baihongyu.com/

你可能感兴趣的文章
Linux 磁盘管理(df fu fdisk mkfs mount)
查看>>
jQuery的事件绑定与触发 - 学习笔记
查看>>
Linux上TCP的几个内核参数调优
查看>>
记一次讲故事机器人的开发-我有故事,让机器人来读
查看>>
seo 回忆录百度基本概念(一)
查看>>
kettle 执行 kjb 临时文件夹 /tmp permission denied 问题
查看>>
netcore中使用session
查看>>
Android 开发学习进程0.25 自定义控件
查看>>
多媒体文件格式全解说(下)--图片
查看>>
淘宝WAP版小BUG分析
查看>>
asp.net打印网页后自动关闭网页【无需插件】
查看>>
【Maven】POM基本概念
查看>>
【Java思考】Java 中的实参与形参之间的传递到底是值传递还是引用传递呢?
查看>>
【设计模式】单例模式
查看>>
远程触发Jenkins的Pipeline任务的并发问题处理
查看>>
entity framework core在独立类库下执行迁移操作
查看>>
Asp.Net Core 2.1+的视图缓存(响应缓存)
查看>>
【wp】HWS计划2021硬件安全冬令营线上选拔赛
查看>>
Ef+T4模板实现代码快速生成器
查看>>
JQuery选择器
查看>>