思路:

求个凸包

旋转卡壳一下

就求出来最远点对了

注意共线情况

也就是说   凸包如果有一堆点共线保留端点即可

//By SiriusRen
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N=;
int n,k,top,now=,ans;
struct P{int x,y;P(){}P(int X,int Y){x=X,y=Y;}}p[N],tb[N];
bool cmp(P a,P b){return a.x==b.x?a.y<b.y:a.x<b.x;}
int operator*(P a,P b){return a.x*b.y-a.y*b.x;}
P operator-(P a,P b){return P(a.x-b.x,a.y-b.y);}
int cross(P a,P b,P c){return (a-c)*(b-c);}
int dis(P a){return a.x*a.x+a.y*a.y;}
int main(){
scanf("%d",&n);
for(int i=;i<=n;i++)scanf("%d%d",&p[i].x,&p[i].y);
sort(p+,p++n,cmp);
for(int i=;i<=n;i++){
while(top>&&cross(tb[top],p[i],tb[top-])<=)top--;
tb[++top]=p[i];
}k=top;
for(int i=n-;i;i--){
while(top>k&&cross(tb[top],p[i],tb[top-])<=)top--;
tb[++top]=p[i];
}
for(int i=;i<top;i++){
while((tb[i+]-tb[i])*(tb[now]-tb[i])<(tb[i+]-tb[i])*(tb[now+]-tb[i])){
now++;if(now==top)now=;
}ans=max(ans,dis(tb[i]-tb[now]));
}printf("%d\n",ans);
}

POJ 2187 凸包+旋转卡壳的更多相关文章

  1. poj 2187【旋转卡壳模板】

    求平面最远点对 #include<iostream> #include<cstdio> #include<algorithm> #include<cmath& ...

  2. poj 2187 Beauty Contest(二维凸包旋转卡壳)

    D - Beauty Contest Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u ...

  3. poj 2079 Triangle (二维凸包旋转卡壳)

    Triangle Time Limit: 3000MS   Memory Limit: 30000KB   64bit IO Format: %I64d & %I64u Submit Stat ...

  4. [USACO2003][poj2187]Beauty Contest(凸包+旋转卡壳)

    http://poj.org/problem?id=2187 题意:老题了,求平面内最远点对(让本渣默默想到了悲剧的AHOI2012……) 分析: nlogn的凸包+旋转卡壳 附:http://www ...

  5. UVA 4728 Squares(凸包+旋转卡壳)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=17267 [思路] 凸包+旋转卡壳 求出凸包,用旋转卡壳算出凸包的直 ...

  6. Code Chef GEOCHEAT(凸包+旋转卡壳+随机化)

    题面 传送门 题解 以下记\(S_i=\{1,2,3,...,i\}\) 我们先用凸包+旋转卡壳求出直径的长度,并记直径的两个端点为\(i,j\)(如果有多条直径随机取两个端点) 因为这个序列被\(r ...

  7. Poj 2187 凸包模板求解

    Poj 2187 凸包模板求解 传送门 由于整个点数是50000,而求凸包后的点也不会很多,因此直接套凸包之后两重循环即可求解 #include <queue> #include < ...

  8. poj 2187 凸包加旋转卡壳算法

    题目链接:http://poj.org/problem?id=2187 旋转卡壳算法:http://www.cppblog.com/staryjy/archive/2009/11/19/101412. ...

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

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

随机推荐

  1. 餐巾(cogs 461)

    [问题描述] 一个餐厅在相继的N天里,第i天需要Ri块餐巾(i=l,2,…,N).餐厅可以从三种途径获得餐巾. (1)购买新的餐巾,每块需p分: (2)把用过的餐巾送到快洗部,洗一块需m天,费用需f分 ...

  2. SharedPreferences保存用户偏好参数

    package com.example.administrator.myapplication; import android.content.Context; import android.cont ...

  3. Ubuntu 16.04升级4.7.0内核后导致Compiz奔溃,问题:compiz[4852]: segfault at 48 ip 00007f88cae087f0 sp 00007ffce354c268 error 4 in libscale.so

    由于硬件的驱动支持问题,升级4.7.0的内核主要是为了能使用Intel HD Graphics 630驱动,但是也出现了相关问题,比如Compiz的特效导致桌面上如果有多个相同程序启动,然后再次点击时 ...

  4. JSTL-XML标签库

    主页:http://www.cnblogs.com/EasonJim/p/6958992.html的分支页. 一.<x:out> <x:out>标签显示XPath表达式的结果, ...

  5. poj 2318 TOYS &amp; poj 2398 Toy Storage (叉积)

    链接:poj 2318 题意:有一个矩形盒子,盒子里有一些木块线段.而且这些线段坐标是依照顺序给出的. 有n条线段,把盒子分层了n+1个区域,然后有m个玩具.这m个玩具的坐标是已知的,问最后每一个区域 ...

  6. server证书安装配置指南(Tomcat 6)

    一.   生成证书请求   1.  安装JDK 安装Tomcat须要JDK支持. 假设您还没有JDK的安装.则能够參考 Java SE Development Kit (JDK) 下载. 下载地址: ...

  7. 魔兽 如何屏蔽F1键弹出帮助菜单

    如下图所示,我在任何时候按F1键,都会自动弹出Windows帮助和支持,事实上这个功能很鸡肋,从来没用过,但是玩魔兽的时候确实必须的,F1控制英雄的,呵呵.   方法还是有的,在任务管理器中找到这个应 ...

  8. uva 439 Knight Moves 骑士移动

    这道题曾经写过,bfs.用队列,不多说了,上代码: #include<stdio.h> #include<stdlib.h> #include<string.h> ...

  9. Redis源代码分析(六)--- ziplist压缩列表

    ziplist和之前我解析过的adlist列表名字看上去的非常像.可是作用却全然不同.之前的adlist主要针对的是普通的数据链表操作. 而今天的ziplist指的是压缩链表.为什么叫压缩链表呢.由于 ...

  10. iOS tableview cell 的展开收缩

    iOS tableview cell 的展开收缩 #import "ViewController.h" @interface ViewController ()<UITabl ...