比赛 HAOI2009 模拟试题1 评测结果 WTTEEEEEEE
题目名称 洞窟探索 最终得分 0
用户昵称 打不死的羊 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-04-21 11:12:43
显示代码纯文本
program hole;
type
fxz1=array[1..150,1..150] of longint;
fxz2=array[1..150] of boolean;
var
f1,f2:text;
i,j,x,y,z,min,k,p,m,n:longint;
map:fxz1;
f:fxz2;
ans:real;
  procedure sc(l,ls,x:longint);
  var
  i:longint;
  begin  if l=m then begin if ls+map[x,p]<=min then min:=ls+map[x,p];end
                else for i:=1 to n do
                     if f[i] then
                     begin f[i]:=false;
                           sc(l+1,ls+map[x,i],i);
                           f[i]:=true;
                     end;
  end;
begin
assign(f1,'hole.in');
assign(f2,'hole.out');
reset(f1);rewrite(f2);
readln(f1,n,m);
for i:=1 to n do
for j:=1 to n do
begin
map[i,j]:=999999;
if i=j then map[i,j]:=0;
end;
for i:=1 to m do
begin
readln(f1,x,y,z);
map[x,y]:=z;
map[y,x]:=z;
end;
for i:=1 to n do
f[i]:=true;
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];
min:=maxlongint;
for p:=1 to n do
begin
f[p]:=false;
sc(1,0,p);
f[p]:=true;
end;
ans:=min/m;
writeln(f2,ans:0:2);
close(f1);close(f2);
end.