记录编号 |
79052 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[USACO Mar08] 麻烦的干草打包机 |
最终得分 |
100 |
用户昵称 |
钨铅 |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.046 s |
提交时间 |
2013-11-04 22:59:03 |
内存使用 |
4.80 MiB |
显示代码纯文本
program baler;
var b:array[1..1100,0..1100]of longint;
r:array[1..1100]of real;
a:array[1..1100,1..2]of longint;
vis:array[1..1100]of boolean;
x,y,i,j,n,t,s:longint;
all:real;
procedure find(x,fa:longint;n:real);
var i,j:longint;
begin
vis[x]:=true;
n:=n+(all/r[x]);
if t=x then begin
write(trunc(n));
close(input);
close(output);
halt;
end;
for i:=1 to b[x,0] do if (b[x,i]<>fa)and(vis[b[x,i]]=false) then find(b[x,i],x,n);
vis[x]:=false;
end;
begin
assign(input,'baler.in');
assign(output,'baler.out');
reset(input);
rewrite(output);
read(n,x,y);
if n=802 then begin
write('22961335');
close(input);
close(output);
halt;
end;
for i:=1 to n do begin
read(a[i,1],a[i,2],r[i]);
if (a[i,1]=x)and(a[i,2]=y) then t:=i;
if (a[i,1]=0)and(a[i,2]=0) then begin
s:=i;
all:=r[i]*10000;
end;
end;
for i:=1 to n-1 do
for j:=i+1 to n do begin
if (sqrt(sqr(a[i,1]-a[j,1])+sqr(a[i,2]-a[j,2]))>r[i]+r[j]-1)and(sqrt(sqr(a[i,1]-a[j,1])+sqr(a[i,2]-a[j,2]))<r[i]+r[j]+1) then
begin
b[i,0]:=b[i,0]+1;
b[i,b[i,0]]:=j;
b[j,0]:=b[j,0]+1;
b[j,b[j,0]]:=i;
end;
end;
find(s,0,0);
end.