#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
struct Point{
int x,y;
Point(int x=0,int y=0):x(x),y(y){}
};
typedef Point Vector;
bool cmp(const Point &p,const Point &q)
{
if(p.x!=q.x) return p.x<q.x;
return p.y<q.y;
}
Vector operator -(Point A,Point B){return Vector(A.x-B.x,A.y-B.y);}
Point p[50010],ch[50010];
int Cross(Vector A,Vector B){return A.x*B.y-A.y*B.x;}
int ConvexHull(Point *p,int n,Point *ch)
{
sort(p,p+n,cmp);
int m=0;
for(int i=0;i<n;i++){
while(m>1&&Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0)m--;
ch[m++]=p[i];}
int k=m;
for(int i=n-2;i>=0;i--)
{
while(m>k&&Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0)m--;
ch[m++]=p[i];
}
if(n>1)
m--;
return m;
}
int Dot(Vector A,Vector B){return A.x*B.x+A.y*B.y;}
int Length(Vector A){return Dot(A,A);}
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
//memset(ch,0,sizeof(ch));
for(int i=0;i<n;i++)
scanf("%d%d",&p[i].x,&p[i].y);
int x=ConvexHull(p,n,ch);
int ans=0;
for(int i=0;i<x-1;i++)
for(int j=i+1;j<x;j++)
{if(Length(ch[i]-ch[j])>ans)
ans=Length(ch[i]-ch[j]);
//if(Length(ch[i]-ch[j])<Length(ch[i]-ch[j-1]))
//break;
}
printf("%d\n",ans);
}
return 0;
}

poj_2187求凸包直径的更多相关文章

  1. UVa 1453 - Squares 旋转卡壳求凸包直径

    旋转卡壳求凸包直径. 参考:http://www.cppblog.com/staryjy/archive/2010/09/25/101412.html #include <cstdio> ...

  2. POJ 2187 Beauty Contest【旋转卡壳求凸包直径】

    链接: http://poj.org/problem?id=2187 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...

  3. 【POJ 2187】Beauty Contest(凸包直径、旋转卡壳)

    给定点集的最远两点的距离. 先用graham求凸包.旋(xuán)转(zhuàn)卡(qiǎ)壳(ké)求凸包直径. ps:旋转卡壳算法的典型运用 http://blog.csdn.net/hanch ...

  4. poj 2187 Beauty Contest , 旋转卡壳求凸包的直径的平方

    旋转卡壳求凸包的直径的平方 板子题 #include<cstdio> #include<vector> #include<cmath> #include<al ...

  5. LA 4728 旋转卡壳算法求凸包的最大直径

    #include<iostream> #include<cstdio> #include<cmath> #include<vector> #includ ...

  6. POJ 3384 Feng Shui 凸包直径 + 半平面交

    G++一直没有过了 换成 C++果断A掉了...It's time to bet RP. 题意:给一个多边形,然后放进去两个圆,让两个圆的覆盖面积尽量最大,输出两个圆心的坐标. 思路:将多边形的边向里 ...

  7. poj 2187:Beauty Contest(计算几何,求凸包,最远点对)

    Beauty Contest Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 26180   Accepted: 8081 D ...

  8. HDU 1392 凸包模板题,求凸包周长

    1.HDU 1392 Surround the Trees 2.题意:就是求凸包周长 3.总结:第一次做计算几何,没办法,还是看了大牛的博客 #include<iostream> #inc ...

  9. Wall--POJ1113(极角排序+求凸包)

    http://poj.org/problem?id=1113 题目大意:现在要给n个点,让你修一个围墙把这些点围起来,距离最小是l 分析  :现在就是求凸包的周长然后再加上一个圆的周长 #includ ...

随机推荐

  1. 利用新版本自带的Zookeeper搭建kafka集群

    安装简要说明新版本的kafka自带有zookeeper,其实自带的zookeeper完全够用,本篇文章以记录使用自带zookeeper搭建kafka集群.1.关于kafka下载kafka下载页面:ht ...

  2. ASP.NET-HttpPostedFileBase file为null的问题

    MVC使用Ajax.BeginForm上传图片时HttpPostedFileBase file为null,Request.Files获取不到文件,问题分析是页面中存在jquery.unobtrusiv ...

  3. 常用类属于哪些jar包

    1.@requestmapping注解,属于org.springframework.web.bind.annotation包下.org.springframework.web jar包. 2.@Res ...

  4. IntelliJ IDEA could not autowire no beans of 'Decoder'

    IntelliJ IDEA could not autowire no beans of  'Decoder' 学习了:http://blog.csdn.net/u012453843/article/ ...

  5. Oracle Table Function

    Oracle Table Function在Oracle9i时引入.完美的兼容了view和存储过程的长处: 应用举例: 1.Table()函数: set feedback off create or ...

  6. bzoj4554: [Tjoi2016&Heoi2016]游戏(二分图匹配)

    4554: [Tjoi2016&Heoi2016]游戏 题目:传送门 题解: 一道很牛逼的匈牙利..和之前模拟赛的一道题有点相似(不过这题不用完美匹配) 我们可以把连续的行和列全部编号(如果之 ...

  7. m_Orchestrate learning system---三、session使用完整流程是什么

    m_Orchestrate learning system---三.session使用完整流程是什么 一.总结 一句话总结: 1.在登录成功之后设置session和cookie 2.在公共控制器里面使 ...

  8. xBIM 基础06 将STEP物理文件转换为XML

    系列目录    [已更新最新开发文章,点击查看详细]  一.STEP标准简介 STEP,它是Standard for the Exchange of Product model data的缩写.产品数 ...

  9. Combobox下拉框两级联动

    下拉框的两级联动是我们开发中经常遇到一种情况.比如一个学生管理系统中,根据年级.科目及姓名查询学生考试成绩,年级和科目都是硬盘中的有限数据(数据库)而学生则可以有用户手动指定,这时在数据库中有年级和科 ...

  10. 学习es6 setter/getter研究

    1.背景 在ES6中,我们对类的定义如下 class Person { // 构造函数 constructor (name) { // 属性初始化 this.name = name; } // 成员方 ...