给出一些正方形。让你求这些正方形顶点之间的最大距离的平方。

//返回点集直径的平方
int diameter2(vector<Point> & points) {
vector<Point> p = ConvexHull(points);
int n = p.size();
if(n==1) return 0;
if(n==2) return Dist2(p[0], p[1]);
p.push_back(p[0]);
int ans = 0;
for(int u = 0, v = 1; u < n; ++u) {
for(;;) {
int diff = Cross(p[u+1]-p[u], p[v+1]-p[v]);
if(diff<=0) {
ans = max(ans, Dist2(p[u], p[v]));
if(diff==0) ans = max(ans, Dist2(p[u], p[v+1]));
break;
}
v = (v+1) % n;
}
}
return ans;
}

LA 4728 Square ,旋转卡壳法求多边形的直径的更多相关文章

  1. BZOJ 1185: [HNOI2007]最小矩形覆盖-旋转卡壳法求点集最小外接矩形(面积)并输出四个顶点坐标-备忘板子

    来源:旋转卡壳法求点集最小外接矩形(面积)并输出四个顶点坐标 BZOJ又崩了,直接贴一下人家的代码. 代码: #include"stdio.h" #include"str ...

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

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

  3. POJ 2079 Triangle(凸包+旋转卡壳,求最大三角形面积)

    Triangle Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 7625   Accepted: 2234 Descript ...

  4. LA 4728 旋转卡壳算法求凸包的最大直径

    #include<iostream> #include<cstdio> #include<cmath> #include<vector> #includ ...

  5. POJ - 2187:Beauty Contest (最简单的旋转卡壳,求最远距离)

    Bessie, Farmer John's prize cow, has just won first place in a bovine beauty contest, earning the ti ...

  6. UVALive 4728 Squares(旋转卡壳)

    Squares The famous Korean IT company  plans to make a digital map of the Earth with help of wireless ...

  7. UVAL 4728 Squares(旋转卡壳)

    Squares [题目链接]Squares [题目类型]旋转卡壳 &题解: 听着算法名字,感觉挺难,仔细一看之后,发现其实很简单,就是依靠所构成三角行面积来快速的找对踵点,就可以省去很多的复杂 ...

  8. Gym - 101635K:Blowing Candles (简单旋转卡壳,求凸包宽度)

    题意:给定N个点,用矩形将所有点覆盖,要求矩形宽度最小. 思路:裸体,旋转卡壳去rotate即可. 最远距离是点到点:宽度是点到边. #include<bits/stdc++.h> #de ...

  9. POJ - 2079:Triangle (旋转卡壳,求最大三角形)

    Given n distinct points on a plane, your task is to find the triangle that have the maximum area, wh ...

随机推荐

  1. 2017 Idea 最简易破解 (无需jar包)(个人整理)

    首先 修改host文件: 文件路径:C:\Windows\System32\drivers\etc\hosts 修改:将“0.0.0.0 account.jetbrains.com”追加到hosts文 ...

  2. 总结html

    1.初识html W3C : 万维网联盟!(World Wide Web Consortium )   创建于1994年,是web技术领域最权威最具有影响力的标准机构!           W3C规定 ...

  3. 安卓手机安装 Charles 证书

    1: 在  Charles 工具栏里点击 Help --- SSL Proxying --- Save Charles Root Certificate,生成 后缀名是 .cer 的文件, 然后上传到 ...

  4. django导出excel

    # coding:utf-8 from django.http import HttpResponse from xlwt import * import StringIO, os from test ...

  5. CF280C Game on Tree 期望

    期望多少次操作,我们可以看做是染黑了多少节点 那么,我们可以用期望的线性性质,求出每个节点被染黑的概率之和(权值为$1$) 一个节点$u$被染黑仅跟祖先有关 我们把$u$到祖先的链抽出来 只要选取链上 ...

  6. iptables配置允许mysql远程访问

    vi /etc/sysconfig/iptables iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCE ...

  7. 2018-2019-2 20162318《网络对抗技术》Exp3 免杀原理与实践

    一.实验内容 1.正确使用msf编码器,msfvenom生成如jar之类的其他文件,veil-evasion),加壳工具),使用shellcode编程 2.通过组合应用各种技术实现恶意代码免杀(如果成 ...

  8. 保存全局Crash报告

    CrashHandler.java UncaughtException处理类,当程序发生Uncaught异常的时候,有该类来接管程序,并记录发送错误报告 package  com.amanda;imp ...

  9. 【BZOJ】4720: [Noip2016]换教室

    4720: [Noip2016]换教室 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 1690  Solved: 979[Submit][Status ...

  10. Substring with Concatenation of All Words 题解

    题意 You are given a string, s, and a list of words, words, that are all of the same length. Find all ...