比赛 20091111 评测结果 AWWWWWWWWW
题目名称 建造路径 最终得分 10
用户昵称 打不死的羊 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-11-11 09:35:13
显示代码纯文本
program roads;
type
fxz1=array[1..1000] of real;
fxz2=array[1..1000,1..1000] of real;
fxz3=array[1..1000] of boolean;
var
f1,f2:text;
i,j,k,a,b,n,m:longint;
min,ans:real;
x,y,ls:fxz1;
map:fxz2;
f:fxz3;




begin assign(f1,'roads.in');
      assign(f2,'roads.out');
      reset(f1);rewrite(f2);
      readln(f1,n,m);
      for i:=1 to n do
      readln(f1,x[i],y[i]);
      for i:=1 to n do
      for j:=1 to n do
      map[i,j]:=sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j]));
      for i:=1 to m do
      begin readln(f1,a,b);
            map[a,b]:=0;
            map[b,a]:=0;
      end;
      for i:=1 to n do
      f[j]:=true;

      for i:=1 to n do
      ls[i]:=map[1,i];
      f[1]:=false;
      for i:=2 to n do
      begin
          min:=maxlongint;
          for j:=1 to n do
          if (f[j])and(ls[j]<min) then begin min:=ls[j];
                                                 k:=j;
                                            end;
          f[k]:=false;
          for j:=1 to n do
          if map[k,j]<ls[j] then ls[j]:=map[k,j];
      end;
      ans:=0;
      for i:=1 to n do
      if ls[i]>0 then ans:=ans+ls[i];
      writeln(f2,ans:0:2);
      close(f1);close(f2);
end.