比赛 |
HAOI2009 模拟试题3 |
评测结果 |
AAAAA |
题目名称 |
医院设置 |
最终得分 |
100 |
用户昵称 |
打不死的羊 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-04-23 09:39:01 |
显示代码纯文本
program hospital;
type
fxz1=array[0..100,0..100] of longint;
fxz2=array[1..100] of longint;
var
f1,f2:text;
i,j,k,m,n,min,ls:longint;
map:fxz1;
p,l,r:fxz2;
begin
assign(f1,'hospital.in');
assign(f2,'hospital.out');
reset(f1);rewrite(f2);
readln(f1,n);
for i:=1 to n do
for j:=1 to n do
map[i,j]:=500;
for i:=1 to n do
begin
readln(f1,p[i],l[i],r[i]);
map[l[i],i]:=1;
map[i,l[i]]:=1;
map[r[i],i]:=1;
map[i,r[i]]:=1;
end;
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if map[i,j]>=map[i,k]+map[k,j] then map[i,j]:=map[i,k]+map[k,j];
for i:=1 to n do
map[i,i]:=0;
for i:=1 to n do
for j:=1 to n do
map[i,j]:=map[i,j]*p[i];
min:=maxlongint;
for i:=1 to n do begin ls:=0;
for j:=1 to n do
begin ls:=ls+map[j,i];
if ls>min then break;
end;
if ls<min then min:=ls;
end;
writeln(f2,min);
close(f1);close(f2);
end.