记录编号 79034 评测结果 AWWWWWWWWW
题目名称 [USACO Mar08] 麻烦的干草打包机 最终得分 10
用户昵称 Gravatar赵寒烨 是否通过 未通过
代码语言 Pascal 运行时间 0.039 s
提交时间 2013-11-04 22:35:50 内存使用 4.40 MiB
显示代码纯文本
var
  size:array [1..1050] of longint;
  f:array [1..1050,1..1050] of longint;
  b:array [1..1050] of boolean;
  a:array [1..1050] of record
    x,y,r:longint;
  end;
  d:array [1..1050] of double;
  n,wx,wy,worked,i,j,st:longint;
  s:double;
function dis(i,j:longint):double;
  begin
    exit(sqrt(sqr(a[i].x-a[j].x)+sqr(a[i].y-a[j].y)));
  end;
procedure dfs(code:longint);
  var
    ans,p:double;
    u,i:longint;
  begin
    if (a[code].x=wx)and(a[code].y=wy) then begin
      ans:=s;
      for i:=1 to worked do
        ans:=ans+d[i];
      writeln(ans:0:0);
      close(input);
      close(output);
      halt;
    end;
    for i:=1 to size[code] do begin
      u:=f[code,i];
      if b[u] then continue;
      b[u]:=true;
      p:=s;
      inc(worked);
      d[worked]:=s;
      s:=s*a[code].r/a[u].r;
      dfs(u);
      dec(worked);
      s:=p;
    end;
  end;
begin
  assign(input,'baler.in');reset(input);
  assign(output,'baler.out');rewrite(output);
  readln(n,wx,wy);
  s:=10000;
  fillchar(b,sizeof(b),false);
  for i:=1 to n do begin
    readln(a[i].x,a[i].y,a[i].r);
    if (a[i].x=0)and(a[i].y=0) then st:=i;
  end;
  for i:=1 to n do
    for j:=i+1 to n do
      if dis(i,j)-(a[i].r+a[j].r)<0.00001 then begin
        inc(size[i]);
        f[i,size[i]]:=j;
        inc(size[i]);
        f[i,size[i]]:=i;
      end;
  b[st]:=true;
  dfs(st);
end.