poj 2187 Beauty Contest 最远点距
/**
求出凸包枚举每个点的矩距离即可 因为凸包上的点可定不多。。
学习: 刚开始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 最远点距的更多相关文章
- poj 2187 Beauty Contest(凸包求解多节点的之间的最大距离)
/* poj 2187 Beauty Contest 凸包:寻找每两点之间距离的最大值 这个最大值一定是在凸包的边缘上的! 求凸包的算法: Andrew算法! */ #include<iostr ...
- poj 2187 Beauty Contest (凸包暴力求最远点对+旋转卡壳)
链接:http://poj.org/problem?id=2187 Description Bessie, Farmer John's prize cow, has just won first pl ...
- poj 2187 Beauty Contest(平面最远点)
Beauty Contest Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 24431 Accepted: 7459 D ...
- POJ 2187 Beauty Contest (求最远点对,凸包+旋转卡壳)
Beauty Contest Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 24283 Accepted: 7420 D ...
- poj 2187:Beauty Contest(计算几何,求凸包,最远点对)
Beauty Contest Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 26180 Accepted: 8081 D ...
- POJ 2187 - Beauty Contest - [凸包+旋转卡壳法][凸包的直径]
题目链接:http://poj.org/problem?id=2187 Time Limit: 3000MS Memory Limit: 65536K Description Bessie, Farm ...
- POJ 2187 Beauty Contest【旋转卡壳求凸包直径】
链接: http://poj.org/problem?id=2187 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...
- poj 2187 Beauty Contest
Beauty Contest 题意:给你一个数据范围在2~5e4范围内的横纵坐标在-1e4~1e4的点,问你任意两点之间的距离的最大值的平方等于多少? 一道卡壳凸包的模板题,也是第一次写计算几何的题, ...
- POJ 2187 Beauty Contest [凸包 旋转卡壳]
Beauty Contest Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 36113 Accepted: 11204 ...
随机推荐
- ios中的银联支付
场景 随着移动互联网的迅猛发展,移动互联已经深深地融入我们的生活.其中,支付方式也是我们生活中经常遇到的情况.所以,在我们的应用中加入支付功能是多么的重要.现在主流的支付接口,一是支付宝类的,一是银联 ...
- 文件上传下载样式 --- bootstrap
在平时工作中,文件上传下载功能属于不可或缺的一部分.bootstrap前端样式框架也使用的比较多,现在根据bootstrap强大的样式模板,自定义一种文件下载的样式. 后续会使用spring MVC框 ...
- iOS 7 标签栏控制器进行模态视图跳转后变成透明
要解决此问题,需要设置tabBar的如下属性: self.tabBar.translucent = NO;
- 使用Maven完成自动化打包并部署到Linux服务器下(Tomcat7)
最近在使用maven,顺便尝试了下tomcat部署.网上找到了很多资料但是都不是最新的,所以贴上比较新的Tomcat7部署代码和配置,方便以后回顾-->测试OK. 1. 首先是配置Tomcat ...
- C++ 字符串指针与字符串数组
在做面试100题中第21题时,发现char *astr="abcdefghijk\0";和char astr[]={"abcdefghijk"};有点区别,以前 ...
- winform代码:关联窗体数据更新,删除dataGridview中选中的一行或多行
一.关联窗体数据更新 关联窗体数据修改时,如果一个为总体数据显示窗体A,另一个为详细修改窗体B,从A进入B,在B中对数据进行修改,然后返回A,这时A窗体的数据需要更新. 我采用最简单的方法,首先保证每 ...
- codeforces 626E. Simple Skewness 三分
题目链接 给n个数, 让你去掉一些数, 使得剩下的数的平均值-中位数的差值最大. 先将数组排序, 然后枚举每一个数作为中位数的情况, 对于每个枚举的数, 三分它的左右区间长度找到一个平均值最大的情况, ...
- [LeetCode]题解(python):097-Interleaving String
题目来源: https://leetcode.com/problems/interleaving-string/ 题意分析: 给定字符串s1,s2,s3,判断s3是否由s1和s2穿插组成.如“abc” ...
- python --appium搭建环境过程 ---新手总结(大牛勿喷,新手互相交流)
首先安装python 安装包:https://yunpan.cn/cSdYZqjJ4xDZ3 访问密码 4bf9 1.安装pip cd 到pip安装包 python setup.py inst ...
- 电脑bios到底是什么?
没有哪个玩电脑的人不知道电脑bios,但是真正能明白bios是什么的?身边却没几个,甚至大多数电脑维修站的人员对bios也不够详细了解.一般人不去关心bios是因为它离我们的电脑真正使用仍有一段距离. ...