题目链接

求平面最大点对。

找凸包 -> 根据凸包运用旋转卡壳算法求最大点对(套用kuang巨模板)

关于旋转卡壳算法

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct point
  5. {
  6. int x,y;
  7. point operator -(const point& rhs)const
  8. {
  9. point ret;
  10. ret.x=x-rhs.x;
  11. ret.y=y-rhs.y;
  12. return ret;
  13. }
  14. int operator *(const point& rhs)const//叉乘
  15. {
  16. return x*rhs.y-y*rhs.x;
  17. }
  18. bool operator <(const point& rhs)const
  19. {
  20. return x<rhs.x||x==rhs.x&&y<rhs.y;
  21. }
  22. } p[],s[];
  23. int top;
  24.  
  25. bool ok(point A,point B,point C) //判断ABC是否是按逆时针顺序给出
  26. {
  27. ;
  28. }
  29. int dist2(point a,point b)
  30. {
  31. return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
  32. }
  33. int rotating_calipers()
  34. {
  35. ;
  36. point v;
  37. ;
  38. ; i < top; i++)
  39. {
  40. v = s[i]-s[(i+)%top];
  41. )%top]-s[cur])) < )
  42. cur = (cur+)%top;
  43. ret = max(ret,max(dist2(s[i],s[cur]),dist2(s[(i+)%top],s[(cur+)%top])));
  44. }
  45. return ret;
  46. }
  47.  
  48. int main()
  49. {
  50. int T;
  51. scanf("%d",&T);
  52. while(T--)
  53. {
  54. int n;
  55. scanf("%d",&n);
  56. ; i<n; i++)
  57. scanf("%d%d",&p[i].x,&p[i].y);
  58.  
  59. sort(p,p+n);
  60. top=;
  61. ; i<n; i++) //求下凸包
  62. {
  63. && !ok(s[top-],s[top-],p[i]))
  64. top--;
  65. s[top++]=p[i];
  66. }
  67. ;
  68. ; i>=; i--) //求上凸包
  69. {
  70. && !ok(s[top-],s[top-],p[i]))
  71. top--;
  72. s[top++]=p[i];
  73. }
  74. --top; // 首尾点相同,故舍去
  75. int ans=rotating_calipers();
  76. printf("%d\n",ans);
  77. }
  78. }

nyoj 253:LK的旅行 【旋转卡壳入门】的更多相关文章

  1. nyoj_253:LK的旅行(旋转卡壳入门)

    题目链接 求平面最大点对. 找凸包 -> 根据凸包运用旋转卡壳算法求最大点对(套用kuang巨模板) 关于旋转卡壳算法 #include<bits/stdc++.h> using n ...

  2. nyoj-253-LK的旅行(Graham算法和旋转卡壳)

    题目链接 /* Name:nyoj-253-LK的旅行 Copyright: Author: Date: 2018/4/27 15:01:36 Description: zyj的模板 */ #incl ...

  3. P1452 Beauty Contest 旋转卡壳

    \(\color{#0066ff}{题目描述}\) 贝茜在牛的选美比赛中赢得了冠军"牛世界小姐".因此,贝西会参观N(2 < = N < = 50000)个农场来传播善 ...

  4. P1452 Beauty Contes(旋转卡壳版)

    题目背景 此处省略1W字^ ^ 题目描述 贝茜在牛的选美比赛中赢得了冠军”牛世界小姐”.因此,贝西会参观N(2 < = N < = 50000)个农场来传播善意.世界将被表示成一个二维平面 ...

  5. 1393: Robert Hood 旋转卡壳 凸包

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1393 http://poj.org/problem?id=2187 Beauty Contest ...

  6. POJ 3608 Bridge Across Islands --凸包间距离,旋转卡壳

    题意: 给你两个凸包,求其最短距离. 解法: POJ 我真的是弄不懂了,也不说一声点就是按顺时针给出的,不用调整点顺序. 还是说数据水了,没出乱给点或给逆时针点的数据呢..我直接默认顺时针给的点居然A ...

  7. 【BZOJ 1069】【SCOI 2007】最大土地面积 凸包+旋转卡壳

    因为凸壳上对踵点的单调性所以旋转卡壳线性绕一圈就可以啦啦啦--- 先求凸包,然后旋转卡壳记录$sum1$和$sum2$,最后统计答案就可以了 #include<cmath> #includ ...

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

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

  9. 【BZOJ-1069】最大土地面积 计算几何 + 凸包 + 旋转卡壳

    1069: [SCOI2007]最大土地面积 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 2707  Solved: 1053[Submit][Sta ...

随机推荐

  1. 002-序列化装换JSON&XML概述

    一.概述 https://github.com/bjlhx15/java-serializer java-serializer 序列化项目 serialize-json-lib:json-lib框架 ...

  2. Failed to load resource: the server responsed with a status of 400 (Bad Request)

    浏览器报错:Failed to load resource: the server responsed with a status of 400 (Bad Request) ajax请求失败,一般情况 ...

  3. DELPHI之全局变量和局部变量

    http://www.cnblogs.com/Stwo/archive/2011/07/11/2102816.html DELPHI之全局变量和局部变量 全局变量: 如果我们在应用程序一个单元中的in ...

  4. Vagrant 手册之 Vagrantfile - 机器设置 config.vm

    原文地址 配置的命名空间:config.vm config.vm 中的设置修改 Vagrant 管理的机器的配置. 1. 可用的设置项 config.vm.boot_timeout Vagrant 等 ...

  5. hdu2602Bone Collector ——动态规划(0/1背包问题)

    Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bone Collec ...

  6. 类型(type)判断

    windows下源文件编码问题 在windows下不要直接右击桌面创建.txt再改成.c,这种方式容易引起编码问题 windows下gvim的设置: 先打开gvim再用:w newfile.c这种方式 ...

  7. TCGA癌症缩写、癌症中英文对照

    Cohort 英文名称 中文名称 ACC Adrenocortical carcinoma 肾上腺皮质癌 BLCA Bladder Urothelial Carcinoma 膀胱尿路上皮癌 BRCA ...

  8. 常用的AJAX弹出层代码

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. [BZOJ3626] [LNOI2014]LCA(树链剖分)

    [BZOJ3626] [LNOI2014]LCA(树链剖分) 题面 给出一棵N个点的树,要求支持Q次询问,每次询问一个点z与编号为区间[l,r]内的点分别求最近公共祖先得到的最近公共祖先深度和.N, ...

  10. P4390 [BOI2007]Mokia 摩基亚

    传送门 对于一个询问 $(xa,ya),(xb,yb)$,拆成 $4$ 个询问并容斥一下 具体就是把询问变成求小于等于 $xb,yb$ 的点数,减去小于等于 $xa-1,yb$ 和小于等于 $xb,y ...