/**
求出凸包枚举每个点的矩距离即可 因为凸包上的点可定不多。。
学习: 刚开始WA 了一次,,因为用int 存的, 一看discuss 里提供的数据,想起来,,应该是越界了。。
后来用longlong 就过了。。
**/
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std; struct point {
long long x,y;
//point (){}
point (double x=,double y=):x(x),y(y){}
};
point p[],ch[]; typedef point Vector; Vector operator -(point a,point b){
return Vector (a.x-b.x,a.y-b.y);
}
long long cross(Vector a,Vector b){
return a.x*b.y-a.y*b.x;
} bool cmp(point a,point b){
if(a.x==b.x)
return a.y<b.y;
return a.x<b.x;
}
long long length(Vector a){
return a.x*a.x+a.y*a.y;
} int convexHull(point *p,int n,point *ch){
sort(p,p+n,cmp);
int m =;
for(int i=;i<n;i++){
while(m>&&cross(ch[m-]-ch[m-],p[i]-ch[m-])<=)
m--;
ch[m++] = p[i];
}
int k = m;
for(int i=n-;i>=;i--){
while(m>k&&cross(ch[m-]-ch[m-],p[i]-ch[m-])<=)
m--;
ch[m++] = p[i];
}
if(n>) m--;
return m;
} int main()
{
int n;
cin>>n;
for(int i=;i<n;i++){
cin>>p[i].x>>p[i].y;
}
int m = convexHull(p,n,ch);
long long max_len = ;
for(int i=;i<m;i++){
for(int j=i+;j<m;j++){
if(length(ch[j]-ch[i])>max_len)
max_len = length(ch[j]-ch[i]);
}
}
cout<<max_len<<endl;
return ;
}

poj 2187 Beauty Contest 最远点距的更多相关文章

  1. poj 2187 Beauty Contest(凸包求解多节点的之间的最大距离)

    /* poj 2187 Beauty Contest 凸包:寻找每两点之间距离的最大值 这个最大值一定是在凸包的边缘上的! 求凸包的算法: Andrew算法! */ #include<iostr ...

  2. poj 2187 Beauty Contest (凸包暴力求最远点对+旋转卡壳)

    链接:http://poj.org/problem?id=2187 Description Bessie, Farmer John's prize cow, has just won first pl ...

  3. poj 2187 Beauty Contest(平面最远点)

    Beauty Contest Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 24431   Accepted: 7459 D ...

  4. POJ 2187 Beauty Contest (求最远点对,凸包+旋转卡壳)

    Beauty Contest Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 24283   Accepted: 7420 D ...

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

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

  6. POJ 2187 - Beauty Contest - [凸包+旋转卡壳法][凸包的直径]

    题目链接:http://poj.org/problem?id=2187 Time Limit: 3000MS Memory Limit: 65536K Description Bessie, Farm ...

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

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

  8. poj 2187 Beauty Contest

    Beauty Contest 题意:给你一个数据范围在2~5e4范围内的横纵坐标在-1e4~1e4的点,问你任意两点之间的距离的最大值的平方等于多少? 一道卡壳凸包的模板题,也是第一次写计算几何的题, ...

  9. POJ 2187 Beauty Contest [凸包 旋转卡壳]

    Beauty Contest Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 36113   Accepted: 11204 ...

随机推荐

  1. HDU ACM 1063 Exponentiation 大实数乘方

    分析:大实数乘方计算. #include<iostream> #include<string> using namespace std; struct BigReal //高精 ...

  2. 一个关于Integer的秘密

    先让大家看一段简单的代码: public static voidmain(String[] args) { Integera = 1; Integerb = 1; Integerc = 222; In ...

  3. 反射,得到Type引用的三种方式

    1.使用System.Object.GetType()得到Type引用 使用一个SportsCar实例得到类型信息 SportsCar sc=new  SportsCar(); Type t=sc.G ...

  4. Jquery的一些取值

    //获取当前节点的html代码(包括当前节点),prop用于获取与设置Html元素的原生属性 $("#tmpMsgObj").prop("outerHTML") ...

  5. javascript函数querySelector

    querySelector用于获得dom节点,可以接受三种类型的参数:id(#),class(.),标签.很像jquery的选择器.不过只能返回一个子孙元素,但是jquery选择器的话,可以返回一组元 ...

  6. bzoj 1042: [HAOI2008]硬币购物 dp+容斥原理

    题目链接 1042: [HAOI2008]硬币购物 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1706  Solved: 985[Submit][ ...

  7. poj 2074 Line of Sight 计算几何

    /** 大意:给定一个建筑--水平放置,给定n个障碍物, 给定一条街道,从街道上能看到整个建筑的最长的连续的区域 思路: 分别确定每一个障碍物所确立的盲区,即----建筑物的终点与障碍物的起点的连线, ...

  8. Output in PowerShell

    Reference article: https://rkeithhill.wordpress.com/2007/09/16/effective-powershell-item-7-understan ...

  9. IOS 使用IOS6苹果地图

    IOS应用程序中使用Map Kit API开发地图应用程序.其核心是MKMapView类的使用.我们可以设置地图显示方式,控制地图,可以在地图上添加标注. 1.显示地图 在Map Kit API中显示 ...

  10. IOS FoundationKit (NSString) 知识汇总

    1. interface 代表类声明,@implement 代表类实现,@encode 代表将object-c 中类型转换成指定字符串 2  当前char * 类型转化为字符串需要转化为NSStrin ...