题意:给定N个点,用矩形将所有点覆盖,要求矩形宽度最小。

思路:裸体,旋转卡壳去rotate即可。

最远距离是点到点;宽度是点到边。

#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define RC rotating_calipers
using namespace std;
const int maxn=;
struct point{
ll x,y;
point(double x=,double y=):x(x),y(y){}
bool operator < (const point &c) const { return x<c.x||(x==c.x&&y<c.y);}
point operator - (const point &c) const { return point(x-c.x,y-c.y);}
};
ll det(point A,point B){ return A.x*B.y-A.y*B.x;}
ll det(point O,point A,point B){ return det(A-O,B-O);}
point a[maxn],ch[maxn];
void convexhull(int n,int &top)
{
sort(a+,a+n+); top=;
for(int i=;i<=n;i++){
while(top>&&det(ch[top-],ch[top],a[i])<=) top--;
ch[++top]=a[i];
}
int ttop=top;
for(int i=n-;i>=;i--){
while(top>ttop&&det(ch[top-],ch[top],a[i])<=) top--;
ch[++top]=a[i];
}
}
double rotating_calipers(point p[],int top)
{
double ans=; int now=;
rep(i,,top-){
while(abs(det(p[i],p[i+],p[now]))<abs(det(p[i],p[i+],p[now+]))){
now++; if(now==top) now=;
}
double tmp=fabs(1.0*det(p[i],p[i+],p[now]));
tmp/=sqrt(1.0*(p[i].x-p[i+].x)*(p[i].x-p[i+].x)+(p[i].y-p[i+].y)*(p[i].y-p[i+].y));
ans=min(ans,tmp);
}
return ans;
}
int main()
{
int N; double S; scanf("%d%lf",&N,&S);
for(int i=;i<=N;i++) scanf("%I64d%I64d",&a[i].x,&a[i].y);
int top; convexhull(N,top);
printf("%.15lf\n",RC(ch,top));
return ;
}

Gym - 101635K:Blowing Candles (简单旋转卡壳,求凸包宽度)的更多相关文章

  1. UVa 1453 - Squares 旋转卡壳求凸包直径

    旋转卡壳求凸包直径. 参考:http://www.cppblog.com/staryjy/archive/2010/09/25/101412.html #include <cstdio> ...

  2. poj 2187 Beauty Contest , 旋转卡壳求凸包的直径的平方

    旋转卡壳求凸包的直径的平方 板子题 #include<cstdio> #include<vector> #include<cmath> #include<al ...

  3. POJ 2187 Beauty Contest【旋转卡壳求凸包直径】

    链接: http://poj.org/problem?id=2187 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...

  4. bzoj1185 [HNOI2007]最小矩形覆盖 旋转卡壳求凸包

    [HNOI2007]最小矩形覆盖 Time Limit: 10 Sec  Memory Limit: 162 MBSec  Special JudgeSubmit: 2081  Solved: 920 ...

  5. Bridge Across Islands POJ - 3608 旋转卡壳求凸包最近距离

    \(\color{#0066ff}{题目描述}\) 几千年前,有一个小王国位于太平洋的中部.王国的领土由两个分离的岛屿组成.由于洋流的冲击,两个岛屿的形状都变成了凸多边形.王国的国王想建立一座桥来连接 ...

  6. POJ 2079 Triangle 旋转卡壳求最大三角形

    求点集中面积最大的三角形...显然这个三角形在凸包上... 但是旋转卡壳一般都是一个点卡另一个点...这种要求三角形的情况就要枚举底边的两个点 卡另一个点了... 随着底边点的递增, 最大点显然是在以 ...

  7. [hdu5251]矩形面积 旋转卡壳求最小矩形覆盖

    旋转卡壳求最小矩形覆盖的模板题. 因为最小矩形必定与凸包的一条边平行,则枚举凸包的边,通过旋转卡壳的思想去找到其他3个点,构成矩形,求出最小面积即可. #include<cstdio> # ...

  8. POJ2187 旋转卡壳 求最长直径

    给定平面上的一些散点集,求最远两点距离的平方值. 题解: 旋转卡壳求出凸包,然后根据单调性,求出最远两点的最大距离 #pragma GCC optimize(2) #pragma G++ optimi ...

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

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

随机推荐

  1. 流量分析系统---redis

    1\启动redis 方法一: 修改了某些配置,具体步骤惨开下面的内容 [root@mini1 ~]# service redis stop/start 方法二: [root@mini1 bin]#cd ...

  2. Python 7 多线程及进程

    进程与线程: 进程的概念: 1.程序的执行实例称为进程. 2.每个进程都提供执行程序所需的资源.一个进程有一个虚拟地址空间.可执行代码.对系统对象的开放句柄.一个安全上下文.一个独特的进程标识符.环境 ...

  3. 小数据池、is 和 ==的区别

    小数据池,在一定情况下出现内存共享(只有int  和 str 才有的)   is 和 ==的区别 id()     打印数据的地址 a  = 'hello' b = 'hello' print(a = ...

  4. jQuery仿苹果样式焦点图插件

    在线演示 本地下载

  5. Docker 监控平台Prometheus

    Prometheus 是一个强大的监控平台,提供了监控数据搜集.存储.处理.可视化和告警一套完整的解决方案. 官方网站:https://prometheus.io

  6. Windows Server 2008 IIS的备份和还原

    Windows Server 2008 IIS的备份和还原 当我们服务器系统有大量的站点和虚拟目录的时候,因为种种原因需要重做系统,那么重装系统后这些站点我们是否只能一个一个的添加,如果有成百上千个站 ...

  7. linux 安装jdk1.7 环境

    由于各Linux开发厂商的不同,因此不同开发厂商的Linux版本操作细节也不一样,今天就来说一下CentOS下JDK的安装: 方法一:手动解压JDK的压缩包,然后设置环境变量 1.在/usr/目录下创 ...

  8. 使用 Apache Spark 让 MySQL 查询速度提升 10 倍以上

    转: https://coyee.com/article/11012-how-apache-spark-makes-your-slow-mysql-queries-10x-faster-or-more ...

  9. VK Cup 2017 - Qualification 1 C 贪心

    是一道很有趣的题目 给出地图和起始点 与要求的步数k 要求走k步 正好回到起始点 输出字典序最小的移动路径 DLRU这样 可以想到DU LR都是相同数量的 于是k必须是一个偶数 然后走了弯路QAQ 从 ...

  10. Python3一些包的下载

    首先在windows的Python扩展包网址:http://www.lfd.uci.edu/~gohlke/pythonlibs/ 这里举例下载opencv3.2.0的安装包 我的电脑是win10,6 ...