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. 单独调用Ueditor的图片上传功能

    <!DOCTYPE html> <html> <head> <title></title> <script src="/sc ...

  2. 关于DB2 SQL0805N找不到程序包的错误解决办法

    DB2在执行SQL语句的时候会使用内部定义的包(package)来保持不同级别的游标的稳定性, 包的名字就是“ULLID.SYSLH2XX“. DB2 里面默认的时候会创建3个这样的包即SYSLH20 ...

  3. C#中winform窗体如何嵌入cmd命令窗口

    解决方法一: 自己放一个文本框,改成黑色,然后输入命令,执行时,你Process.Start cmd ,此时CMD窗口不显示,然后,将CMD的返回值,再取出来,设回文本框. 如何用这种方法实时获取cm ...

  4. DNS map file in windows

    Edit "C:\WINDOWS\system32\drivers\etc\hosts", add the IP to DNS name mapping.

  5. 使用vhd灌装系统——测试系统专用

    需要使用工具imagex.exe 一. 创建虚拟磁盘: 1.diskpart 2.create vdisk file=c:\test\leiyue.vhd maximum=20000 [tpye=ex ...

  6. UI4_UITableViewSectionIndex

    // AppDelegate.m // UI4_UITableViewSectionIndex // // Created by zhangxueming on 15/7/14. // Copyrig ...

  7. java随笔 乱腾腾的 一些东西

    调用requonse.getWriter()方法时可实现文本字符串数据输出,调用response.getOutputStream()方法可现实字节流数据的输出.两种输出方式threadlocal模式和 ...

  8. Vim保存文件命令 ":wq" 与 ":x" 的区别

    CSDN转载 [1] Vim是Unix/Linux系统最常用的编辑器之一,在保存文件时,我通常选择":wq",因为最开始学习vim的时候,就只记住了几个常用的命令:也没有细究命令的 ...

  9. sql临时表和表变量

    1. 为什么要使用表变量 表变量是从2000开始引入的,微软认为与本地临时表相比,表变量具有如下优点:  a.与其他变量的定义一样,表变量具有良好的定义范围,并会被自动清除:  b.在存储过程中使用表 ...

  10. i18next-页面层语言国际化js框架介绍

    因为工作需要,最近研究了下网站语言国际化的问题,根据当前项目架构,寻求一种较好的解决方案.首先总结下项目中语言切换实现方式大概有以下几种: 1,一种语言一套页面,如:index_CN.html,ind ...