1. /**
  2. 求出凸包枚举每个点的矩距离即可 因为凸包上的点可定不多。。
  3. 学习: 刚开始WA 了一次,,因为用int 存的, 一看discuss 里提供的数据,想起来,,应该是越界了。。
  4. 后来用longlong 就过了。。
  5. **/
  6. #include <iostream>
  7. #include <algorithm>
  8. #include <cmath>
  9. using namespace std;
  10.  
  11. struct point {
  12. long long x,y;
  13. //point (){}
  14. point (double x=,double y=):x(x),y(y){}
  15. };
  16. point p[],ch[];
  17.  
  18. typedef point Vector;
  19.  
  20. Vector operator -(point a,point b){
  21. return Vector (a.x-b.x,a.y-b.y);
  22. }
  23. long long cross(Vector a,Vector b){
  24. return a.x*b.y-a.y*b.x;
  25. }
  26.  
  27. bool cmp(point a,point b){
  28. if(a.x==b.x)
  29. return a.y<b.y;
  30. return a.x<b.x;
  31. }
  32. long long length(Vector a){
  33. return a.x*a.x+a.y*a.y;
  34. }
  35.  
  36. int convexHull(point *p,int n,point *ch){
  37. sort(p,p+n,cmp);
  38. int m =;
  39. for(int i=;i<n;i++){
  40. while(m>&&cross(ch[m-]-ch[m-],p[i]-ch[m-])<=)
  41. m--;
  42. ch[m++] = p[i];
  43. }
  44. int k = m;
  45. for(int i=n-;i>=;i--){
  46. while(m>k&&cross(ch[m-]-ch[m-],p[i]-ch[m-])<=)
  47. m--;
  48. ch[m++] = p[i];
  49. }
  50. if(n>) m--;
  51. return m;
  52. }
  53.  
  54. int main()
  55. {
  56. int n;
  57. cin>>n;
  58. for(int i=;i<n;i++){
  59. cin>>p[i].x>>p[i].y;
  60. }
  61. int m = convexHull(p,n,ch);
  62. long long max_len = ;
  63. for(int i=;i<m;i++){
  64. for(int j=i+;j<m;j++){
  65. if(length(ch[j]-ch[i])>max_len)
  66. max_len = length(ch[j]-ch[i]);
  67. }
  68. }
  69. cout<<max_len<<endl;
  70. return ;
  71. }

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. C、C++中引用与指针的区别

    1:引用的和指针在概念上的区别 引用是变量的别名,例如 int m; int &n=m; 引用作为一个别名.它在逻辑上不是独立的,它的存在具有依附性,所以引用必须在一开始就被初始化,而且其引用 ...

  2. FusionCharts 学习总结

    FusionCharts和Charts一样都是对数据进行统计并绘制成图标的控件,但FusionCharts带有跨浏览器的flash图表组件解决方案,功能更为强大.. 在这里我将采用Js来加载Fusio ...

  3. 微型 ORM 的第一篇 DapperLambda发布

    引言:因为接触过多个ORM,但使用的时候都遇到了各自的一些不够理想的地方,从最早开始开始公司自己分装的,到后面用EF,以及Dapper和DapperExtensions  到现在用的FluentDat ...

  4. 反射以及 getDeclaredMethods()和getMethods()区别

    内容转载自http://blog.csdn.net/ljphhj/article/details/12858767 package cn.lee.demo; import java.lang.refl ...

  5. beanUtils操作bean的属性

    beanUtils操纵bean属性: 需要jar包commons-beanutils-x.x.x.jar    同时commons-beanutils-x.x.x.jar需要commons-loggi ...

  6. JavaScript 验证提交文件的信息

    前言 目前工作任务终于告一段落了,今天发现之前写的文件上传的代码有点小瑕疵,就是上传图片如果超过 2M 就会出错,因为七牛云好像限制了上传图片的大小,所以就用 JavaScript 在文件选中之后,上 ...

  7. app自动化的webView页面测试思路(appium工具)。

    1.获取当前activity多有的handles,然后去遍历它,发现webView后切换到webView对应模式,就可以了.进一步操作webView的话用下面的方法(driver.getPageSou ...

  8. COB封装的优势

    随着固态照明技术的不断进步,COB(chip-on-board)封装技术得到越来越多的重视,由于COB光源有热阻低,光通量密度高,眩光少,发光均匀等特性,在室内外照明灯具中得到了广泛的应用,如筒灯,球 ...

  9. Qt5位置相关函数异同详解(附源码)

    Qt5中提供了丰富的位置和区域大小相关函数.下面讲一讲他们的区别. 主要函数: 1.x(),y(),pos():获取整个窗体左上角的坐标位置. 2.frameGeometry():获取整个窗体左上角的 ...

  10. C#使用Windows API 隐藏/显示 任务栏 (FindWindowEx, ShowWindow)

    原文 C#使用Windows API 隐藏/显示 任务栏 (FindWindowEx, ShowWindow) 今天,有网友询问,如何显示和隐藏任务栏? 我这里,发布一下使用Windows API 显 ...