/*这是用的有旋转卡壳的思想。
首先确定i,j,对k进行循环,知道找到第一个k使得cross(i,j,k)>cross(i,j,k+1),如果k==i进入下一次循环。
对j,k进行旋转,每次循环之前更新最大值,然后固定一个j,同样找到一个k使得cross(i,j,k)>cross(i,j,k+1)。对j进行++操作,继续进行下一次,
知道j==k为止。
*/ #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath> using namespace std; struct point{
double x,y;
}p[1000100];
int n; int ans[1000100],st[1000100],cnt,stop; bool cmp(point A, point B){
if(A.y<B.y) return true;
else if(A.y==B.y){
if(A.x<B.x) return true;
}
return false;
} double multi(point a,point b,point c){
point p1; p1.x=a.x-c.x; p1.y=a.y-c.y;
point p2; p2.x=b.x-c.x; p2.y=b.y-c.y;
return p1.x*p2.y-p1.y*p2.x;
} void slove(){
cnt=stop=0;
st[stop++]=0; st[stop++]=1;
for(int i=2;i<n;i++){
while(stop>1&&multi(p[i],p[st[stop-1]],p[st[stop-2]])>=0) stop--;
st[stop++]=i;
}
for(int i=0;i<stop;i++)
ans[cnt++]=st[i];
stop=0; st[stop++]=n-1; st[stop++]=n-2;
for(int i=n-3;i>=0;i--){
while(stop>1&&multi(p[i],p[st[stop-1]],p[st[stop-2]])>=0) stop--;
st[stop++]=i;
}
for(int i=1;i<stop-1;i++)
ans[cnt++]=st[i];
/* for(int i=0;i<cnt;i++)
cout<<ans[i]<<endl;
cout<<endl;*/
} double Triangle(point a,point b,point c){
point p1; p1.x=a.x-c.x; p1.y=a.y-c.y;
point p2; p2.x=b.x-c.x; p2.y=b.y-c.y;
return fabs((p1.x*p2.y-p1.y*p2.x)*1.0)/2.0;
} double Area(){
int q; int j;
double anst=0;
for(int i=0;i<cnt;i++){
j=(i+1)%cnt;
q=(j+1)%cnt;
while(Triangle(p[ans[i]],p[ans[j]],p[ans[q]])<=Triangle(p[ans[i]],p[ans[j]],p[ans[(q+1)%cnt]])&&q!=i)
q=(q+1)%cnt; //枚举了当前最远的K点
anst=max(anst,Triangle(p[ans[i]],p[ans[j]],p[ans[q]]));
if(q==i) continue;
while(j!=i&&q!=i){
anst=max(anst,Triangle(p[ans[i]],p[ans[j]],p[ans[q]]));
while(Triangle(p[ans[i]],p[ans[j]],p[ans[q]])<=Triangle(p[ans[i]],p[ans[j]],p[ans[(q+1)%cnt]])&&q!=i)
q=(q+1)%cnt;
j=(j+1)%cnt;
} }
return anst;
} int main(){
while(scanf("%d",&n)!=EOF){
// if(n==-1) break;
for(int i=0;i<n;i++){
scanf("%lf%lf",&p[i].x,&p[i].y);
}
sort(p,p+n,cmp);
slove();
double anst=0;
anst=max(anst,Area());
printf("%.2lf\n",anst);
}
return 0;
}

  

HDU 3934的更多相关文章

  1. hdu 3934 Summer holiday (凸包+旋转卡壳)

    Problem - 3934 晚上为了演示给师弟看水平序的凸包是多么的好写,于是就随便找了一题凸包,25min居然1y掉了.. 代码如下: #include <cmath> #includ ...

  2. hdu 3934&&poj 2079 (凸包+旋转卡壳+求最大三角形面积)

    链接:http://poj.org/problem?id=2079 Triangle Time Limit: 3000MS   Memory Limit: 30000K Total Submissio ...

  3. hdu 3934 Summer holiday(凸包最大内接三角形)

    求n个点能组成的最大三角形,一发旋转卡壳模板题... #include<algorithm> #include<iostream> #include<cstring> ...

  4. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  6. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  7. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  9. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

随机推荐

  1. U32670 小凯的数字 数学

    这是洛谷一个比赛中的一道题,和去年NOIP D1T1挺像.我看了一眼之后想“这不是小学奥数吗?求一个数字和就好了呀”...然后,60,剩下T了,gg. 只好看正解,但是一脸懵逼???然后看了证明,c* ...

  2. 如何检查ASTGO是限制并发的体验版呢?

    由于网上曾经流传过一段时间来自ASTGO官方的ASTGO体验版(下载地址:http://www.51voip.org/post/33.html),这个版本有个特色就是安装后不需要激活码激活即可打通电话 ...

  3. Django day13 form组件, 渲染错误信息, 全局钩子

    一:from组件 二:渲染错误信息 三:全局钩子

  4. 「LOJ10150」括号配对

    [题目] Hecy 又接了个新任务:BE 处理.BE 中有一类被称为 GBE. 以下是 GBE 的定义: 空表达式是 GBE 如果表达式 A 是 GBE,则 [A] 与 (A) 都是 GBE 如果 A ...

  5. 5.13redis图形化工具---idea中配置redis密码

    安装window下的redis,redis可视化管理工具(Redis Desktop Manager)安装,基础使用,实例化项目 源博客地址:https://www.cnblogs.com/cheng ...

  6. @PathVariable注解的使用和@Requestparam

    一. @PathVariable @PathVariable这是一个路径映射格式的书写方式注解,在类映射路径的后加上/{对应方法参数中属性@PathVariable("code") ...

  7. 获取Json中特定的值

      假如我们得到了一个json的数据:json===>   {"Head":{"TransCode":"X1009","Tr ...

  8. SSIS 无法在 unicode 和非 unicode 字符串数据类型之间转换

    最近在学SSIS,遇到一个问题,把平面文件源的数据导入到EXCEL中. 平面文件源的对象是CSV,读进来的PhoneNumber是 DT_STR 然后倒入Excel 对应列建立的是longtext 一 ...

  9. 【SQL】字符型函数

    1. ASCII ASCII(American Standard Code for Information Interchange,美国信息交换标准代码)是基于拉丁字母的一套电脑编码系统. 1) 返回 ...

  10. WEB笔记-2 剖析CSS规则

    2.1 剖析CSS规则   规则即指令,其声明了需要修改的元素及要应用给元素的样式.     2.2 为文档添加样式的三种方法   行内样式:直接写在HTML文档标签中的style属性当中,行内元素只 ...