zoukankan      html  css  js  c++  java
  • bzoj1069

    四边形的问题可以转化为三角形处理
    穷举对角线,然后处理上下两个三角形,旋转卡壳

     1 var x,y:array[0..5010] of double;
     2     q:array[0..5010] of longint;
     3     l,r,i,j,k,t,n:longint;
     4     ans:double;
     5 
     6 function max(a,b:double):double;
     7   begin
     8     if a>b then exit(a) else exit(b);
     9   end;
    10 
    11 function cross(i,j,k,r:longint):double;
    12   begin
    13     exit((x[i]-x[j])*(y[k]-y[r])-(x[k]-x[r])*(y[i]-y[j]));
    14   end;
    15 
    16 procedure swap(var a,b:double);
    17   var c:double;
    18   begin
    19     c:=a;
    20     a:=b;
    21     b:=c;
    22   end;
    23 
    24 procedure sort(l,r: longint);
    25   var i,j: longint;
    26       p,q:double;
    27 
    28   begin
    29     i:=l;
    30     j:=r;
    31     p:=x[(l+r) shr 1];
    32     q:=y[(l+r) shr 1];
    33     repeat
    34       while (x[i]<p) or (x[i]=p) and (y[i]<q) do inc(i);
    35       while (p<x[j]) or (p=x[j]) and (q<y[j]) do dec(j);
    36       if not(i>j) then
    37       begin
    38         swap(x[i],x[j]);
    39         swap(y[i],y[j]);
    40         inc(i);
    41         j:=j-1;
    42       end;
    43     until i>j;
    44     if l<j then sort(l,j);
    45     if i<r then sort(i,r);
    46   end;
    47 
    48 begin
    49   readln(n);
    50   for i:=1 to n do
    51     readln(x[i],y[i]);
    52   sort(1,n);
    53   q[1]:=1;
    54   t:=1;
    55   for i:=2 to n do
    56   begin
    57     while (t>1) and (cross(q[t],q[t-1],i,q[t-1])<=0) do dec(t);
    58     inc(t);
    59     q[t]:=i;
    60   end;
    61   k:=t;
    62   for i:=n-1 downto 1 do
    63   begin
    64     while (t>k) and (cross(q[t],q[t-1],i,q[t-1])<=0) do dec(t);
    65     inc(t);
    66     q[t]:=i;
    67   end;
    68   for i:=2 to t-1 do
    69     q[i+t-1]:=q[i];
    70   for i:=1 to t-1 do
    71   begin
    72     l:=i+1;
    73     r:=i+3;
    74     while (r<i+t-2) and (cross(q[i+2],q[i],q[r],q[i])<cross(q[i+2],q[i],q[r+1],q[i])) do inc(r);
    75     ans:=max(ans,cross(q[i+1],q[i],q[i+2],q[i])+cross(q[i+2],q[i],q[r],q[i]));
    76     for j:=i+3 to i+t-2 do
    77     begin
    78       while (l<j-1) and (cross(q[l+1],q[i],q[j],q[i])>cross(q[l],q[i],q[j],q[i])) do inc(l);
    79       while (r<i+t-2) and (cross(q[j],q[i],q[r+1],q[i])>cross(q[j],q[i],q[r],q[i])) do inc(r);
    80       ans:=max(ans,cross(q[l],q[i],q[j],q[i])+cross(q[j],q[i],q[r],q[i]));
    81     end;
    82   end;
    83   ans:=ans/2;
    84   writeln(ans:0:3);
    85 end.
    View Code
  • 相关阅读:
    03.yaml语法和playbook写法
    02.ansible的常用模块
    01.ansible基本配置与使用
    24.删除表名
    23.MySQL的备份与恢复
    22.更改表名
    MySQL的表操作
    MySQL的库操作
    MySQL的用户管理
    数据库及MySQL概述
  • 原文地址:https://www.cnblogs.com/phile/p/4472975.html
Copyright © 2011-2022 走看看