比赛 |
HAOI2009 模拟试题1 |
评测结果 |
WWWEETEETE |
题目名称 |
洞窟探索 |
最终得分 |
0 |
用户昵称 |
maxiem |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-04-21 11:29:33 |
显示代码纯文本
program hole;
var
table:array [1..150,1..150] of longint;
flag:array [1..150] of boolean;
way:array [1..150] of integer;
sum,tmp:int64;
n,m,a,b,d,i,j:word;
t:extended;
procedure prim(root,left:integer;s:int64);
var i,j:integer;
begin
flag[root]:=true;way[m-left]:=root;
if left<>0 then begin
for i:=1 to n do if (table[root,i]<>-1) and (flag[i]=false) then begin
tmp:=s;
for j:=1 to m-left do if table[way[j],i]=-1 then table[way[j],i]:=table[way[j],way[m-left]]+table[root,i];
for j:=1 to m-left do tmp:=tmp+table[way[j],i];
prim(i,left-1,tmp);
end;
end
else if s<sum then if s/(m*(m-1)/2)<t then t:=s/(m*(m-1)/2);
end;
begin
fillchar (table,sizeof(table),$FF);
fillchar (flag,sizeof(flag),0);
assign (input,'hole.in');
reset (input);
readln (n,m);
for i:=1 to m do begin
readln (a,b,d);
table[a,b]:=d;
table[b,a]:=d;
end;
t:=maxlongint;sum:=maxlongint;
for i:=1 to n do prim(i,m-1,0);
close (input);
assign (output,'hole.out');
rewrite (output);
writeln (t:0:2);
close (output);
end.