旋转卡壳就是先求出凸包。然后在凸包上枚举四边形的对角线两側分别找面积最大的三角形

因为在两側找面积最大的三角形的顶点是单调的所以复杂度就是n2

单调的这个性质能够自行绘图感受一下,似乎比較显然

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#define ll long long
#define N 2002
using namespace std;
struct W{double x,y;}a[N],st[N];
int n,top;
W operator-(W a,W b)
{
return (W){a.x-b.x,a.y-b.y};
}
double dis(W a,W b)
{
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
double operator*(W a,W b)
{
return a.x*b.y-a.y*b.x;
}
bool operator<(W c,W d)
{
double t=(c-a[1])*(d-a[1]);
if(t==0)return dis(c,a[1])<dis(d,a[1]);
return t<0;
}
void Graham()
{
int k=1;
for(int i=2;i<=n;i++)
if(a[k].y>a[i].y||(a[k].y==a[k].y&&a[k].x>a[i].x))
k=i;
swap(a[k],a[1]);sort(a+1,a+n+1);
st[++top]=a[1],st[++top]=a[2];
for(int i=3;i<=n;i++)
{
while(top>1&&(a[i]-st[top-1])*(st[top]-st[top-1])<=0)top--;
st[++top]=a[i];
}
}
double Rotating_caliper()
{
double mx=0;st[top+1]=a[1];
int a,b;
for(int x=1;x<=top;x++)
{
a=x%top+1,b=(x+2)%top+1;
for(int y=x+2;y<=top;y++)
{
while(a%top+1!=y&&(st[y]-st[x])*(st[a+1]-st[x])>(st[y]-st[x])*(st[a]-st[x]))a=a%top+1;
while(b%top+1!=x&&(st[b+1]-st[x])*(st[y]-st[x])>(st[b]-st[x])*(st[y]-st[x]))b=b%top+1;
mx=max(mx,(st[y]-st[x])*(st[a]-st[x])+(st[b]-st[x])*(st[y]-st[x]));
}
}
return mx;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%lf%lf",&a[i].x,&a[i].y);
Graham();
printf("%.3lf",Rotating_caliper()/2);
return 0;
}

1069: [SCOI2007]最大土地面积|旋转卡壳的更多相关文章

  1. BZOJ 1069: [SCOI2007]最大土地面积(旋转卡壳)

    题目链接~ 1069: [SCOI2007]最大土地面积 思路很简单,极角排序求完凸包后,在凸包上枚举对角线,然后两边分别来两个点旋转卡壳一下,搞定! 不过计算几何的题目就是这样,程序中间的处理还是比 ...

  2. BZOJ 1069: [SCOI2007]最大土地面积 [旋转卡壳]

    1069: [SCOI2007]最大土地面积 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 2978  Solved: 1173[Submit][Sta ...

  3. bzoj 1069 [SCOI2007]最大土地面积——旋转卡壳

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1069 发现 n 可以 n^2 .所以枚举对角线,分开的两部分三角形就可以旋转卡壳了. 注意坐 ...

  4. bzoj1069 [SCOI2007]最大土地面积 旋转卡壳

    1069: [SCOI2007]最大土地面积 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 3767  Solved: 1501[Submit][Sta ...

  5. bzoj 1069 [SCOI2007]最大土地面积(旋转卡壳)

    1069: [SCOI2007]最大土地面积 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2277  Solved: 853[Submit][Stat ...

  6. 1069: [SCOI2007]最大土地面积

    1069: [SCOI2007]最大土地面积 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 2961  Solved: 1162[Submit][Sta ...

  7. 【BZOJ】1069: [SCOI2007]最大土地面积(凸包+旋转卡壳)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1069 显然这四个点在凸包上,然后枚举两个点找上下最大的三角形即可. 找三角形表示只想到三分QAQ.. ...

  8. bzoj 1069: [SCOI2007]最大土地面积 凸包+旋转卡壳

    题目大意: 二维平面有N个点,选择其中的任意四个点使这四个点围成的多边形面积最大 题解: 很容易发现这四个点一定在凸包上 所以我们枚举一条边再旋转卡壳确定另外的两个点即可 旋(xuan2)转(zhua ...

  9. ●BZOJ 1069 [SCOI2007]最大土地面积

    题链: http://www.lydsy.com/JudgeOnline/problem.php?id=1069 题解: 计算几何,凸包,旋转卡壳 其实和这个题差不多,POJ 2079 Triangl ...

随机推荐

  1. 走进 Cake for .NET

    一.什么是 Cake Cake(C# Make) 是一个使用 C#  DSL 面向 Task 的跨平台构建自动化系统,像编译代码,复制文件和文件夹,运行单元测试,压缩文件和构建 NuGet 包. 更多 ...

  2. 文本检查点web_reg_find和web_find两个函数的区别

    LR脚本实战:文本检查点web_reg_find和web_find两个函数的区别   web_reg_find是先注册(register)后查找的:使用时将它放在请求语句的前面. 而web_find是 ...

  3. iwebshop 自动给css js链接加版本信息

    lib/core/tag_class.php case 'theme:': $path = $matches[4]; $exts = strtolower(substr($matches[4], st ...

  4. hdu 1556 Color the ball(线段树区间维护+单点求值)

    传送门:Color the ball Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/3276 ...

  5. PAT L3-001. 凑零钱

    $01$背包,路径记录,贪心. 可以将物品从大到小排序之后进行背包,同时记录路径. #include<map> #include<set> #include<ctime& ...

  6. go chapter 2 - read file(yaml)

    func main() { data, err := ioutil.ReadFile("D:/test/widua.go") if err != nil { fmt.Println ...

  7. Codeforces Round #307 (Div. 2) E. GukiZ and GukiZiana(分块)

    E. GukiZ and GukiZiana time limit per test 10 seconds memory limit per test 256 megabytes input stan ...

  8. 解决PHPExcel长数字串显示为科学计数

    在excel中如果在一个默认的格中输入或复制超长数字字符串,它会显示为科学计算法,例如身份证号码,解决方法是把表格设置文本格式或在输入前加一个单引号. 使用PHPExcel来生成excel,也会遇到同 ...

  9. [BZOJ5011][JXOI2017]颜色

    5011: [Jx2017]颜色 Time Limit: 30 Sec  Memory Limit: 512 MBSubmit: 84  Solved: 46[Submit][Status][Disc ...

  10. 【动态规划】mr351-办签证

    [题目大意] xuzhenyi要办个签证.办证处是一座M层的大楼,1<=M<=100. 每层楼都有N个办公室,编号为1..N(1<=N<=500).每个办公室有一个签证员. 签 ...