比赛 HAOI2009 模拟试题1 评测结果 WWWEETETTT
题目名称 洞窟探索 最终得分 0
用户昵称 bly1991 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-04-21 11:25:27
显示代码纯文本
program bly(input,output);
const
 max=999999999;
var
 m,n:integer;
 min:real;
 g,a:array[1..150,1..150]of longint;
 less:array[1..150,1..150]of integer;
procedure clear;
var i,j:integer;
begin
 for i:=1 to 150 do
  for j:=1 to 150 do begin
   a[i,j]:=0;
   less[i,j]:=0;
   g[i,j]:=max;
  end;
end;
procedure ini;
var i,j,x,y,l:integer;
begin
 assign(input,'hole.in');assign(output,'hole.out');
 reset(input);rewrite(output);
 readln(n,m);
 clear;
 while not eof(input) do begin
  readln(x,y,l);
  g[x,y]:=l;
 end;
end;
procedure floyd;
var i,j,k:integer;
begin
 for i:=1 to n do
  for j:=1 to n do begin
   a[i,j]:=g[i,j];
   if a[i,j]<>max then less[i,j]:=2;
  end;
 for k:=1 to n do
  for i:=1 to n do
   for j:=1 to n do begin
    if(i=k)or(j=k)or(i=j)then continue;
    if a[i,k]+a[k,j]<a[i,j]then begin
     a[i,j]:=a[i,k]+a[k,j];
     less[i,j]:=less[i,k]+1;
    end;
   end;
end;
procedure main;
var i,j:integer;sum:longint;
begin
 sum:=m*(m-1)div 2;
 min:=9999999999;
 for i:=1 to n do
  for j:=1 to n do
   if(less[i,j]=m)and(a[i,j]*2/sum<min)then min:=a[i,j]*2/sum;
 writeln(min:0:2);
 close(input);close(output);
end;
begin
 ini;
 floyd;
 main;
end.