油滴
题目大意:在一个长方形框子里,最多有N个相异的点,在其中任何一个点上放一个很小的油滴,那么这个油滴会一直扩展,直到接触到其他油滴或者框子的边界。必须等一个油滴扩展完毕才能放置下一个油滴。那么应该按照怎样的顺序在这 N个点上放置油滴,才能使放置完毕后所有油滴占据的总体积最大呢?(不同的油滴不会相互融合)
注意,油滴是圆形的……
乱搞就行了。。
program Neayo; const inf='oil.in'; ouf='oil.out'; var i,j,k,n,x1,x2,y1,y2:longint; ans,s,min:real; x,y:array[0..6]of longint; r:array[0..6]of real; put:array[0..6]of boolean; procedure init; begin assign(input,inf);assign(output,ouf); reset(input);rewrite(output); readln(n); readln(x1,y1,x2,y2); for i:=1 to n do readln(x[i],y[i]); ans:=maxlongint; close(input); end; function judge(i,j:longint):real; var d:real; begin d:=sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j])); s:=d-r[j]; exit(s); end; procedure count; var i:longint; begin s:=0; for i:=1 to n do if put[i]then s:=s+r[i]*r[i]*pi; s:=abs(x1-x2)*abs(y1-y2)-s; if s<ans then ans:=s; end; function inside(p:longint):boolean; var i:longint; begin for i:=1 to n do if put[i] then begin if sqrt(sqr(x[p]-x[i])+sqr(y[p]-y[i]))<=r[i] then exit(true); end; exit(false); end; procedure dfs(time:longint); var i,j:longint; begin if time=n+1 then exit; for i:=1 to n do if (not put[i])and(not inside(i)) then begin min:=maxlongint; if abs(x[i]-x1)<min then min:=abs(x[i]-x1); if abs(x[i]-x2)<min then min:=abs(x[i]-x2); if abs(y[i]-y1)<min then min:=abs(y[i]-y1); if abs(y[i]-y2)<min then min:=abs(y[i]-y2); for j:=1 to n do if put[j] then if judge(i,j)<min then min:=s; put[i]:=true; r[i]:=min; count; dfs(time+1); put[i]:=false; r[i]:=0; end; end; begin init; dfs(1); writeln(round(ans)); close(output); end.