比赛 20111102 评测结果 AAAAAAAAAA
题目名称 麻烦的干草打包机 最终得分 100
用户昵称 lizhe 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2011-11-03 09:28:08
显示代码纯文本
program baler;
var
  i,j,n,xt,yt,n0:longint;
  x,y,r:array[1..1050]of real;
  flag:array[1..1050]of boolean;
  d:array[1..1050,1..1050]of boolean;
  sum:real;
procedure init;
begin
  assign(input,'baler.in');
  reset(input);
  assign(output,'baler.out');
  rewrite(output);
  read(n,xt,yt);
  for i:=1 to n do
  begin
    read(x[i],y[i],r[i]);
    if (x[i]=0) and (y[i]=0) then n0:=i
  end;
  fillchar(flag,sizeof(flag),true);
  flag[n0]:=false;
  fillchar(d,sizeof(d),false);
  for i:=1 to n do
    for j:=1 to n do
      if abs(sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j]))-(r[i]+r[j]))<0.00001 then
        d[i,j]:=true
end;

procedure print;
begin
  sum:=sum+10000;
  writeln(trunc(sum));
  close(input);
  close(output);
  halt
end;

procedure dfs(ll:longint;xx,yy,rr,ss:real);
var
  l:longint;
  v:real;
begin
  if (xx=xt) and (yy=yt) then
    print
  else
    for l:=1 to n do
      if flag[l] and d[l,ll] then
      begin
        flag[l]:=false;
        v:=ss*rr/r[l];
        sum:=sum+v;
        dfs(l,x[l],y[l],r[l],v);
	      sum:=sum-v
      end
end;

begin
  init;
  dfs(n0,0,0,r[n0],10000)
end.