比赛 |
HAOI2009 模拟试题3 |
评测结果 |
AAAAA |
题目名称 |
医院设置 |
最终得分 |
100 |
用户昵称 |
wo shi 刘畅 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2012-06-28 16:52:51 |
显示代码纯文本
var
i,j,k,x,y:longint;
ans,now,n:int64;
p:array[0..10000]of int64;
f:array[0..200,0..200]of int64;
begin
assign(input,'hospital.in'); reset(input);
assign(output,'hospital.out'); rewrite(output);
readln(n);
for i:=1 to n do
for j:=1 to n do
f[i,j]:=maxlongint div 2;
for i:=1 to n do
begin
readln(p[i],x,y);
f[i,x]:=1;
f[x,i]:=1;
f[y,i]:=1;
f[i,y]:=1;
end;
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if f[i,k]+f[k,j]<f[i,j] then
f[i,j]:=f[i,k]+f[k,j];
ans:=maxlongint;
for i:=1 to n do
begin
now:=0;
for j:=1 to n do
if j<>i then
inc(now,f[i,j]*p[j]);
if now<ans then ans:=now;
end;
writeln(ans);
close(input);
close(output);
end.