比赛 20120925 评测结果 AAAAAAAAAA
题目名称 油滴扩展 最终得分 100
用户昵称 makeecat 运行时间 0.003 s
代码语言 Pascal 内存使用 0.17 MiB
提交时间 2012-09-25 20:53:59
显示代码纯文本
Const
    ProgramName='oilbox';
Type
    point=array[1..2]of double;
Var
    i,j,k,n,m,l,s,t,x,y:longint;
    a:array[0..10]of point;
    v:array[0..10]of boolean;
    p1,p2,pp:point;
    b:array[0..10]of longint;
    r:array[0..10]of double;
    tt:double;
    t1:double;
    ans:double;
    now:longint;
    maxr:double;
 
Procedure Pin;
var
    i,j,k:longint;
begin
    readln(n);
    readln(p1[1],p1[2],p2[1],p2[2]);
    for i:=1 to n do
        readln(a[i,1],a[i,2]);
end;
 
 
 
Function min(a1,a2,a3,a4:double):double;
begin
    min:=a1;
    if min>a2 then min:=a2;
    if min>a3 then min:=a3;
    if min>a4 then min:=a4;
end;
 
 
Function dis(x1,y1,x2,y2:double):double;
begin
    dis:=sqrt(sqr(x1-x2)+sqr(y1-y2));
end;
 
 
Function inside(x,y,r:double):boolean;
begin
    inside:=true;
    if x-r<p1 [1] then exit(false);
    if x+r>p2[1] then exit(false);
    if y-r<p2 [2] then exit(false);
    if y+r>p1[2] then exit(false);
end;
 
Function solve:double;
begin
    solve:=abs(p1[1]-p2[1])*abs(p1[2]-p2[2]);
    fillchar(r,sizeof(r),0);
    for i:=1 to n do
        begin
            now:=b[i];
            maxr:=10000000;
            maxr:=min(abs(p1[1]-a[now,1]),abs(p2[1]-a[now,1]),
                abs(p1[2]-a[now,2]),abs(p2[2]-a[now,2]));
            for j:=1 to i-1 do
                    if maxr>dis(a[now,1],a[now,2],a[b[j],1],a[b[j],2])-r[b[j]] then
                        maxr:=dis(a[now,1],a[now,2],a[b[j],1],a[b[j],2])-r[b[j]];
            if maxr>0 then
                begin
                    solve:=solve-pi*maxr*maxr;
                    r[now]:=maxr;
                end;
        end;
end;
 
 
Procedure dfs(x:longint);
var
    i,j,k:longint;
begin
    if x=n+1 then
        begin
            tt:=solve;
            if ans>tt then
                ans:=tt;
            exit;
        end;
    for i:=1 to n do
        if not v[i] then
            begin
                b[x]:=i;
                v[i]:=true;
                dfs(x+1);
                v[i]:=false;
            end;
end;
 
 
Procedure Main;
var
    i,j,k:longint;
begin
    ans:=100000000;
    fillchar(v,sizeof(v),false);
    dfs(1);
end;
 
 
Procedure Pout;
var
    i,j,k:longint;
begin
    writeln(round(ans));
end;
 
 
begin
    assign(input,ProgramName+'.in');
    assign(output,ProgramName+'.out');
    reset(input);
    rewrite(output);
    pin;
    main;
    pout;
    close(input);
    close(output);
end.