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 ...
随机推荐
- C、C++中引用与指针的区别
1:引用的和指针在概念上的区别 引用是变量的别名,例如 int m; int &n=m; 引用作为一个别名.它在逻辑上不是独立的,它的存在具有依附性,所以引用必须在一开始就被初始化,而且其引用 ...
- FusionCharts 学习总结
FusionCharts和Charts一样都是对数据进行统计并绘制成图标的控件,但FusionCharts带有跨浏览器的flash图表组件解决方案,功能更为强大.. 在这里我将采用Js来加载Fusio ...
- 微型 ORM 的第一篇 DapperLambda发布
引言:因为接触过多个ORM,但使用的时候都遇到了各自的一些不够理想的地方,从最早开始开始公司自己分装的,到后面用EF,以及Dapper和DapperExtensions 到现在用的FluentDat ...
- 反射以及 getDeclaredMethods()和getMethods()区别
内容转载自http://blog.csdn.net/ljphhj/article/details/12858767 package cn.lee.demo; import java.lang.refl ...
- beanUtils操作bean的属性
beanUtils操纵bean属性: 需要jar包commons-beanutils-x.x.x.jar 同时commons-beanutils-x.x.x.jar需要commons-loggi ...
- JavaScript 验证提交文件的信息
前言 目前工作任务终于告一段落了,今天发现之前写的文件上传的代码有点小瑕疵,就是上传图片如果超过 2M 就会出错,因为七牛云好像限制了上传图片的大小,所以就用 JavaScript 在文件选中之后,上 ...
- app自动化的webView页面测试思路(appium工具)。
1.获取当前activity多有的handles,然后去遍历它,发现webView后切换到webView对应模式,就可以了.进一步操作webView的话用下面的方法(driver.getPageSou ...
- COB封装的优势
随着固态照明技术的不断进步,COB(chip-on-board)封装技术得到越来越多的重视,由于COB光源有热阻低,光通量密度高,眩光少,发光均匀等特性,在室内外照明灯具中得到了广泛的应用,如筒灯,球 ...
- Qt5位置相关函数异同详解(附源码)
Qt5中提供了丰富的位置和区域大小相关函数.下面讲一讲他们的区别. 主要函数: 1.x(),y(),pos():获取整个窗体左上角的坐标位置. 2.frameGeometry():获取整个窗体左上角的 ...
- C#使用Windows API 隐藏/显示 任务栏 (FindWindowEx, ShowWindow)
原文 C#使用Windows API 隐藏/显示 任务栏 (FindWindowEx, ShowWindow) 今天,有网友询问,如何显示和隐藏任务栏? 我这里,发布一下使用Windows API 显 ...