题目链接

求平面最大点对。

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

关于旋转卡壳算法

#include<bits/stdc++.h>
using namespace std;

struct point
{
    int x,y;
    point operator -(const point& rhs)const
    {
        point ret;
        ret.x=x-rhs.x;
        ret.y=y-rhs.y;
        return ret;
    }
    int operator *(const point& rhs)const//叉乘
    {
        return x*rhs.y-y*rhs.x;
    }
    bool operator <(const point& rhs)const
    {
        return x<rhs.x||x==rhs.x&&y<rhs.y;
    }
} p[],s[];
int top;

bool ok(point A,point B,point C)    //判断ABC是否是按逆时针顺序给出
{
    ;
}
int dist2(point a,point b)
{
    return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
int rotating_calipers()
{
    ;
    point v;
    ;
    ; i < top; i++)
    {
        v = s[i]-s[(i+)%top];
        )%top]-s[cur])) < )
            cur = (cur+)%top;
        ret = max(ret,max(dist2(s[i],s[cur]),dist2(s[(i+)%top],s[(cur+)%top])));
    }
    return ret;
}

int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int n;
        scanf("%d",&n);
        ; i<n; i++)
            scanf("%d%d",&p[i].x,&p[i].y);

        sort(p,p+n);
        top=;
        ; i<n; i++)  //求下凸包
        {
             && !ok(s[top-],s[top-],p[i]))
                top--;
            s[top++]=p[i];
        }
        ;
        ; i>=; i--)  //求上凸包
        {
             && !ok(s[top-],s[top-],p[i]))
                top--;
            s[top++]=p[i];
        }
        --top;    //    首尾点相同,故舍去
        int ans=rotating_calipers();
        printf("%d\n",ans);
    }
}

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. [NOIP2016]蚯蚓 题解

    题目描述 本题中,我们将用符号[c]表示对c向下取整,例如:[3.0」= [3.1」= [3.9」=3.蛐蛐国最近蚯蚓成灾了!隔壁跳蚤国的跳蚤也拿蚯蚓们没办法,蛐蛐国王只好去请神刀手来帮他们消灭蚯蚓. ...

  2. windows连接ubuntu服务器方式

    如图,打开cmd, 输入 ssh imkow@www.dorian.vip 参数解析: ssh:secure shell的缩写 imknow  是用户名 www.dorian.vip 是域名,没有域名 ...

  3. Step3 - How to: Host and Run a Basic Windows Communication Foundation Service

    This is the third of six tasks required to create a Windows Communication Foundation (WCF) applicati ...

  4. 在google chrome浏览器上安装 Vue Devtools工具

    [转]https://www.cnblogs.com/tanyongli/p/7554045.html Vue.js devtools是基于google chrome浏览器的一款调试vue.js应用的 ...

  5. 牛客网编程练习(华为机试在线训练)-----求int型正整数在内存中存储时1的个数

    题目描述 输入一个int型的正整数,计算出该int型数据在内存中存储时1的个数. 输入描述: 输入一个整数(int类型) 输出描述: 这个数转换成2进制后,输出1的个数 示例1 输入 5 输出 2 P ...

  6. Dapper - a simple object mapper for .Net

    Dapper - a simple object mapper for .Net Release Notes Located at stackexchange.github.io/Dapper Pac ...

  7. C. Roads in Berland

    题目链接: http://codeforces.com/problemset/problem/25/C 题意: 给一个最初的所有点与点之间的最短距离的矩阵.然后向图里加边,原有的边不变,问加边后的各个 ...

  8. Gradient Descent with Momentum and Nesterov Momentum

    在Batch Gradient Descent及Mini-batch Gradient Descent, Stochastic Gradient Descent(SGD)算法中,每一步优化相对于之前的 ...

  9. ArrayBlockingQueue使用

    阻塞与非阻塞: 阻塞: 阻塞调用是没有获得资源则挂起进程,被挂起的进程进入休眠状态,调用的函数只有在得到结果之后才返回,进程继续. 对象是否处于阻塞模式和函数是不是阻塞调用有很强的相关性,但并不是一一 ...

  10. Emmet-前端开发神器

    地址:https://segmentfault.com/a/1190000007812543 Emmet是一款编辑器插件,支持多种编辑器支持.在前端开发中,Emmet 使用缩写语法快速编写 HTML. ...