uva12307(旋转卡壳)
省选前练模板系列
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=,inf=1e9;
const double eps=1e-;
int dcmp(double a, double b)
{
if (a < b - eps) return -;
else if (a > b + eps) return ;
else return ;
}
struct vec{
double x,y,ang;
vec(){};
vec(double a,double b){x=a,y=b;}
vec operator-(vec a){return vec(x-a.x,y-a.y);}
vec operator+(vec a){return vec(x+a.x,y+a.y);}
bool operator<(const vec&p) const
{
return dcmp(x,p.x)< || (dcmp(x,p.x)== && y < p.y);
}
}p[maxn],ch[maxn];
int n,m,pp,mi,k;
double A,P;
double cross(vec a,vec b){return a.x*b.y-b.x*a.y;}
double dot(vec a,vec b){return a.x*b.x+a.y*b.y;}
double dis(vec a,vec b){return sqrt((double)dot(a-b,a-b));}
int main(){
while(scanf("%d",&n)!=EOF&&n){
m=;A=1e15;P=1e15;
for(int i=;i<n;++i){
scanf("%lf%lf",&p[i].x,&p[i].y);
}
sort(p,p+n);
for(int i=;i<n;++i){
while(m>&&cross(ch[m-]-ch[m-],p[i]-ch[m-])<=)m--;
ch[m++]=p[i];
}
k=m;
for(int i=n-;i>=;--i){
while(m>k&&cross(ch[m-]-ch[m-],p[i]-ch[m-])<=)m--;
ch[m++]=p[i];
}
if(n>)--m;
for(int i=;i<m;++i)cout<<ch[i].x<<' '<<ch[i].y<<endl;
ch[m]=ch[];
int t=,l=,r=;
for(int b=;b<m;++b){
while(cross(ch[b+]-ch[b],ch[t+]-ch[t])>eps)t=(t+)%m;
while(dot(ch[b+]-ch[b],ch[r+]-ch[r])>eps)r=(r+)%m;
if(b==)l=(r+)%m;
while(dot(ch[b+]-ch[b],ch[l+]-ch[l])<-eps)l=(l+)%m;
double d=dis(ch[b+],ch[b]);
double h=(double)cross(ch[b+]-ch[b],ch[t]-ch[b])/d;
double w=(double)(dot(ch[r]-ch[b],ch[b+]-ch[b])-dot(ch[b+]-ch[b],ch[l]-ch[b]))/d;
A=min(A,*(h+w));P=min(P,h*w);
}
printf("%.2lf %.2lf\n",P,A);
}
return ;
}
/*
*/
uva12307(旋转卡壳)的更多相关文章
- 1393: Robert Hood 旋转卡壳 凸包
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1393 http://poj.org/problem?id=2187 Beauty Contest ...
- POJ 3608 Bridge Across Islands --凸包间距离,旋转卡壳
题意: 给你两个凸包,求其最短距离. 解法: POJ 我真的是弄不懂了,也不说一声点就是按顺时针给出的,不用调整点顺序. 还是说数据水了,没出乱给点或给逆时针点的数据呢..我直接默认顺时针给的点居然A ...
- 【BZOJ 1069】【SCOI 2007】最大土地面积 凸包+旋转卡壳
因为凸壳上对踵点的单调性所以旋转卡壳线性绕一圈就可以啦啦啦--- 先求凸包,然后旋转卡壳记录$sum1$和$sum2$,最后统计答案就可以了 #include<cmath> #includ ...
- 【POJ 2187】Beauty Contest(凸包直径、旋转卡壳)
给定点集的最远两点的距离. 先用graham求凸包.旋(xuán)转(zhuàn)卡(qiǎ)壳(ké)求凸包直径. ps:旋转卡壳算法的典型运用 http://blog.csdn.net/hanch ...
- 【BZOJ-1069】最大土地面积 计算几何 + 凸包 + 旋转卡壳
1069: [SCOI2007]最大土地面积 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 2707 Solved: 1053[Submit][Sta ...
- [USACO2003][poj2187]Beauty Contest(凸包+旋转卡壳)
http://poj.org/problem?id=2187 题意:老题了,求平面内最远点对(让本渣默默想到了悲剧的AHOI2012……) 分析: nlogn的凸包+旋转卡壳 附:http://www ...
- 【POJ】2187 Beauty Contest(旋转卡壳)
http://poj.org/problem?id=2187 显然直径在凸包上(黑书上有证明).(然后这题让我发现我之前好几次凸包的排序都错了QAQ只排序了x轴.....没有排序y轴.. 然后本题数据 ...
- 【BZOJ】1069: [SCOI2007]最大土地面积(凸包+旋转卡壳)
http://www.lydsy.com/JudgeOnline/problem.php?id=1069 显然这四个点在凸包上,然后枚举两个点找上下最大的三角形即可. 找三角形表示只想到三分QAQ.. ...
- hdu 3934&&poj 2079 (凸包+旋转卡壳+求最大三角形面积)
链接:http://poj.org/problem?id=2079 Triangle Time Limit: 3000MS Memory Limit: 30000K Total Submissio ...
随机推荐
- python基础与docker
创建虚拟环境python3 -m venv venv (说明:python 2.X 并不支持) 激活虚拟环境macOS/Linux: source venv/bin/activateWindows: ...
- Pandas分组级运算和转换
分组级运算和转换 假设要添加一列的各索引分组平均值 第一种方法 import pandas as pd from pandas import Series import numpy as np df ...
- AVL树实现记录
https://github.com/xieqing/avl-tree An AVL Tree Implementation In C There are several choices when i ...
- python跨平台注释
使python程序运行在window以外的平台上 !# user/bin/python
- Python开发【初始篇】:Linux下安装Python3
Linux系统默认自带python2.6的版本,这个版本被系统很多程序所依赖,所以建议不要轻易删除,除非你能解决其他程序的依赖问题.如果使用最新的Python3需要进行编译安装源码包,这样就对系统默认 ...
- js 中格式化显示时间
function getMyDateTime(str){ var oDate = new Date(str), oYear = oDate.getFullYear(), oMonth = oDate. ...
- pandas用法之二
1,函数应用 ①map() 将函数作用于一个Series的每一个函数(不能是DataFrame) 类似于Python的高阶函数map() 函数可以是Numpy中的通用函数,也可以是自定义函数 优点:代 ...
- WebSocket 实现链接 群聊(low low low 版本)
py 文件: """ 下载 gevent-websocket 0.10.1 基于Flask + geventWebSocket 建立连接,发送消息,实现群消息功能. &q ...
- SpringMvc中Hashmap操作遇到 java.util.ConcurrentModificationException: null
代码按照网上修改为类似,还不能解决问题 for (Iterator<String> it = target.keySet().iterator(); it.hasNext(); ) { i ...
- jmeter导入DB数据再优化
由于同一个迭代中每天都在执行.之前设计的思路是同个迭代只执行一次插入DB操作!! 因而没有在插入数据前没有做版本.产品类型.页面类型.接口名.接口名是否相等判断操作. 因此,若是这些条件相等,数据不是 ...