BZOJ 1069: [SCOI2007]最大土地面积(旋转卡壳)
题目链接~
1069: [SCOI2007]最大土地面积
思路很简单,极角排序求完凸包后,在凸包上枚举对角线,然后两边分别来两个点旋转卡壳一下,搞定!
不过计算几何的题目就是这样,程序中间的处理还是比较麻烦的,写的时候要很小心,特别是存点和枚举的时候要注意是个循环。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm> #define For(i,a,b) for(register int i=a;i<=b;++i)
#define Dwn(i,a,b) for(register int i=a;i>=b;--i)
#define Re register using namespace std; const int N=; struct P{
double x,y;
}st[N],O,p[N];
int n,top=-; P operator -(P a,P b){
P t; t.x=a.x-b.x; t.y=a.y-b.y; return t;
}
double operator *(P a,P b){
return a.x*b.y-b.x*a.y;
}
double Dis(P a,P b){
return sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) );
}
int Xx(P a){
if(a.x-O.x> &&a.y-O.y>=)return ;
if(a.x-O.x<=&&a.y-O.y> )return ;
if(a.x-O.x< &&a.y-O.y<=)return ;
if(a.x-O.x>=&&a.y-O.y< )return ;
}
bool cmp(const P a,const P b){
int aX=Xx(a);
int bX=Xx(b);
if(aX!=bX)return aX<bX;
double cx= (a-O)*(b-O);
if(cx==)return a.x<b.x;
else return cx>;
}
bool cmpY(const P a,const P b){
return a.y<b.y;
} void TuBao(){
st[++top]=p[];
st[++top]=p[];
For(i,,n+){
while( (p[i]-st[top-])*(st[top]-st[top-])>= ) top--;
st[++top]=p[i];
}
} double ans=;
void SpinStir(){
P p1,p2;
int i1,i2;
For(x,,top-){
i1=(x+)%top; p1=st[i1];
i2=(x+)%top; p2=st[i2];
For(y,x+,top-){
int Ni; P Np; Ni=(i1+)%top;
Np=st[Ni];
while(Ni!=x&&(Np-st[y])*(st[x]-st[y])>(p1-st[y])*(st[x]-st[y])){
i1=Ni; p1=Np; Ni=(i1+)%top; Np=st[Ni];
} Ni=(i2+)%top;
Np=st[Ni];
while(Ni!=y&&(Np-st[x])*(st[y]-st[x])>(p2-st[x])*(st[y]-st[x])){
i2=Ni; p2=Np; Ni=(i2+)%top; Np=st[Ni];
} double Sm=(p1-st[y])*(st[x]-st[y])/ + (p2-st[x])*(st[y]-st[x])/;
ans=max(ans,Sm);
}
}
} int main(){
//freopen("ex.in","r",stdin); scanf("%d",&n);
For(i,,n){
scanf("%lf%lf",&p[i].x,&p[i].y);
}
sort(p+,p+n+,cmpY);
O=p[];
sort(p+,p+n+,cmp);
p[n+]=p[];
TuBao();
SpinStir();
printf("%.03lf",ans);
return ; }
BZOJ 1069: [SCOI2007]最大土地面积(旋转卡壳)的更多相关文章
- BZOJ 1069: [SCOI2007]最大土地面积 [旋转卡壳]
1069: [SCOI2007]最大土地面积 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 2978 Solved: 1173[Submit][Sta ...
- bzoj 1069 [SCOI2007]最大土地面积——旋转卡壳
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1069 发现 n 可以 n^2 .所以枚举对角线,分开的两部分三角形就可以旋转卡壳了. 注意坐 ...
- 1069: [SCOI2007]最大土地面积|旋转卡壳
旋转卡壳就是先求出凸包.然后在凸包上枚举四边形的对角线两側分别找面积最大的三角形 因为在两側找面积最大的三角形的顶点是单调的所以复杂度就是n2 单调的这个性质能够自行绘图感受一下,似乎比較显然 #in ...
- bzoj 1069 [SCOI2007]最大土地面积(旋转卡壳)
1069: [SCOI2007]最大土地面积 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 2277 Solved: 853[Submit][Stat ...
- bzoj1069 [SCOI2007]最大土地面积 旋转卡壳
1069: [SCOI2007]最大土地面积 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 3767 Solved: 1501[Submit][Sta ...
- bzoj 1069: [SCOI2007]最大土地面积 凸包+旋转卡壳
题目大意: 二维平面有N个点,选择其中的任意四个点使这四个点围成的多边形面积最大 题解: 很容易发现这四个点一定在凸包上 所以我们枚举一条边再旋转卡壳确定另外的两个点即可 旋(xuan2)转(zhua ...
- ●BZOJ 1069 [SCOI2007]最大土地面积
题链: http://www.lydsy.com/JudgeOnline/problem.php?id=1069 题解: 计算几何,凸包,旋转卡壳 其实和这个题差不多,POJ 2079 Triangl ...
- [BZOJ]1069: [SCOI2007]最大土地面积
题目大意:给出二维平面上n个点,求最大的由这些点组成的四边形面积.(n<=2000) 思路:求出凸包后旋转卡壳枚举对踵点对作为四边形的对角线,枚举或二分另外两个点,复杂度O(n^2)或O(nlo ...
- BZOJ 1069 [SCOI2007]最大土地面积 ——计算几何
枚举对角线,然后旋转卡壳即可. #include <map> #include <cmath> #include <queue> #include <cstd ...
随机推荐
- C# 计时器 以“天时分秒毫秒”形式动态增加显示
参考:http://zhidao.baidu.com/link?url=j-jxQJenrO54BSKJ_IkXWbhdDqbVLUyyenjjSGs8G0xdisgBZ0EMhzyWgARSFct6 ...
- Linux学习之路(二)文件处理命令之下
分区格式化: 一块分区想要使用的话,要格式化.格式化主要有两个工作,1,把分区分成等大小的数据块,每个数据块一般为4KB.2在分区之前建一个分区表,给第一个文件建一行相关数据,在分区表里保存了它的io ...
- Log4j 与 logback对比、及使用配置
二.参考文档 1.Log4j 与 logback对比.及使用配置
- CodeForces - 204C Little Elephant and Furik and Rubik
CodeForces - 204C Little Elephant and Furik and Rubik 个人感觉是很好的一道题 这道题乍一看我们无从下手,那我们就先想想怎么打暴力 暴力还不简单?枚 ...
- C#工程引用dll如何配置
C#工程引用需要注意的事项: <ItemGroup Condition="'$(Configuration)|$(Platform)' == &a ...
- 2011年浙大:Twin Prime Conjecture
Twin Prime Conjecture Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- ClientSocket.h ClientSocket.cpp
ClientSocket.h #pragma once // CClientSocket 命令目标 #include "ClientProDlg.h" #include " ...
- 要把target下面虚拟路径的项目文件…
源码进不去,要检查target下面的项目文件,要删除掉. 版权声明:本文为博主原创文章,未经博主允许不得转载.
- 1、R-reshape2-cast
1.cast: 长型数据转宽型数据 (1).acast,dcast的区别在于输出结果.acast 输出结果为vector/matrix/array,dcast 输出结果为data.frame. ...
- Ajax的调试错误信息的输出
error: function(xhr, status, error) { console.log(xhr); console.log(status); console.log(error); }