Description

在某块平面土地上有N个点,你可以选择其中的任意四个点,将这片土地围起来,当然,你希望这四个点围成的多边形面积最大。
Input

第1行一个正整数N,接下来N行,每行2个数x,y,表示该点的横坐标和纵坐标。
Output

最大的多边形面积,答案精确到小数点后3位。
Sample Input
5
0 0
1 0
1 1
0 1
0.5 0.5
Sample Output
1.000

HINT

数据范围 n<=2000, |x|,|y|<=100000

先求凸包

然后枚举四边形的对角线,分别找到距离最远的两个点更新答案(这两个点都是单调的),总复杂度是O(n^2)的

哪里写挫了,超慢,总时间1600ms

 const
maxn=;
type
point=record
x,y:double;
end;
var
a:array[..maxn]of point;
n:longint;
min:point; function cj(a,b,c:point):double;
begin
exit((a.x-c.x)*(b.y-c.y)-(b.x-c.x)*(a.y-c.y));
end; procedure swap(var x,y:point);
var
t:point;
begin
t:=x;x:=y;y:=t;
end; procedure sort(l,r:longint);
var
i,j:longint;
y:point;
begin
i:=l;
j:=r;
y:=a[(l+r)>>];
repeat
while cj(y,a[i],min)< do
inc(i);
while cj(y,a[j],min)> do
dec(j);
if i<=j then
begin
swap(a[i],a[j]);
inc(i);
dec(j);
end;
until i>j;
if i<r then sort(i,r);
if j>l then sort(l,j);
end; procedure init;
var
i:longint;
begin
read(n);
min.x:=maxlongint;
min.y:=maxlongint;
for i:= to n do
begin
read(a[i].x,a[i].y);
if (a[i].x<min.x) or ((a[i].x=min.x) and (a[i].y<min.y)) then min:=a[i];
end;
i:=n;
while i> do
begin
if (a[i].x=min.x) and (a[i].y=min.y) then
begin
a[i]:=a[n];
dec(n);
end
else dec(i);
end;
sort(,n);
inc(n);
a[n]:=min;
a[]:=min;
end; var
q:array[..maxn]of longint;
f:array[..maxn,..]of double;
tot,lasta,lastb:longint;
ans:double; function up(var x:double;y:double):boolean;
begin
if x<y then
begin
x:=y;
exit(true);
end;
exit(false);
end; function down(var x:double;y:double):boolean;
begin
if x>y then
begin
x:=y;
exit(true);
end;
exit(false);
end; procedure work;
var
i,j:longint;
begin
for i:= to n do
begin
while (tot>) and (cj(a[i],a[q[tot]],a[q[tot-]])>=) do
dec(tot);
inc(tot);
q[tot]:=i;
end;
for i:= to tot- do
begin
f[i+,]:=-maxlongint;
f[i+,]:=;
for j:= to n do
if up(f[i+,],cj(a[q[i+]],a[q[j]],a[q[i]])) then lasta:=j;
lastb:=i;
for j:=i+ to tot do
begin
f[j,]:=cj(a[q[j]],a[q[lasta]],a[q[i]]);
f[j,]:=cj(a[q[j]],a[q[lastb]],a[q[i]]);
while up(f[j,],cj(a[q[j]],a[q[lasta mod tot+]],a[q[i]])) do
lasta:=lasta mod tot+;
while down(f[j,],cj(a[q[j]],a[q[lastb mod tot+]],a[q[i]])) do
lastb:=lastb mod tot+;
up(ans,f[j,]-f[j,]);
end;
end;
writeln(ans/::);
end; begin
init;
work;
end.

1069: [SCOI2007]最大土地面积 - BZOJ的更多相关文章

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    题目大意:给出二维平面上n个点,求最大的由这些点组成的四边形面积.(n<=2000) 思路:求出凸包后旋转卡壳枚举对踵点对作为四边形的对角线,枚举或二分另外两个点,复杂度O(n^2)或O(nlo ...

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

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

随机推荐

  1. 每天一道LeetCode--374. Guess Number Higher or Lower

    We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to gues ...

  2. C# DateTime 日期加1天 减一天 加一月 减一月 等方法(转)

    //今天 DateTime.Now.Date.ToShortDateString(); //昨天,就是今天的日期减一 DateTime.Now.AddDays(-).ToShortDateString ...

  3. 分享10 个超酷的 HTML5/CSS3 应用及源码

    1.HTML5视频破碎重组特效,强大视觉冲击 HTML5视频播放器很多,但是HTML5视频特效还是很少见的,这款HTML5视频破碎重组特效非常刺激,给人强大的视觉冲击.点击视频任意地方,HTML5将会 ...

  4. ThinkPHP中的视图

    ThinkPHP中的视图View 1.什么是视图View 所谓的视图就是用户可视化操作界面. 2.视图View组成 view类(模板引擎类似Smarty) 模板文件(html模板) 3.视图的定义 默 ...

  5. c语言 char*类型作为中间变量将许多字符串保存到一个数组的问题

    char*是一个字符串指针,如下面的程序value_作为一个中间变量用来在for循环中scanf输入的值的接收者,然后将value_保存到array中,但是一下程序会出现一个问题就是当你跳出这个函数时 ...

  6. 用Windows API函数(CreateFile/ReadFile/WriteFile/CloseHandle)完成文件拷贝程序(初级版)

    文件拷贝程序 程序类型:Console 参数:源文件名   目的文件名 要求:1.只能使用Windows API函数(CreateFile/ReadFile/WriteFile/CloseHandle ...

  7. 使用tortoisegit管理git 和 权限验证

    1 安装Git 2 安装Tortoise 3 在git.oschina 或者 github上创建项目 4 Tortoise配置 TortoiseGit 使用扩展名为ppk的密钥,而不是ssh-keyg ...

  8. 批处理测试局域网网络连通性ping1-255

    for /l %%1 in (1 1 255)do ping /n 1 192.168.1.%%1       ##bat下 运行 for /l %i in (1,1,254) do ping -n ...

  9. Ubuntu14.04忘记root密码的解决方法

    电脑20多天没用忘记密码了,下面是在网上找到的一个解决办法,其它的和这个也大概相同.因为其中有些缺漏,没能给我解决问题.通过分析最终问题还是解决了,现解决方案的关键点记录一下.希望能方便到其它人. 1 ...

  10. 更改windows服务的配置文件app.config

    /// <summary> /// 获取每次处理记录数 /// </summary> /// <returns></returns> private s ...