比赛 20091111 评测结果 AEWWWWWEEE
题目名称 建造路径 最终得分 10
用户昵称 ReimBurSe. 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-11-11 09:25:03
显示代码纯文本
Program roads;

Type
abc=record
 x,y:longint;
end;
sc=array [1..1000] of abc;
sc1=array [1..1000,1..1000] of real;
sc2=array [1..1000] of boolean;

Var
z:sc;
s:sc1;
i,j:longint;
n,m,nn:longint;
xx,yy,pp,qq:longint;
temp,min,l:real;
panduan:sc2;

Begin
assign(input,'roads.in');
assign(output,'roads.out');
reset(input);
rewrite(output);
readln(n,m);
for i:=1 to n do
 for j:=1 to n do
  s[i,j]:=999999999;
for i:=1 to n do panduan[i]:=false;
for i:=1 to n do readln(z[i].x,z[i].y);
for i:=1 to m do
 begin
  readln(xx,yy);
  s[xx,yy]:=-1;
  panduan[xx]:=true;
  panduan[yy]:=true;
 end;
nn:=n-1-m;
for i:=1 to n do
 begin
  for j:=1 to n do
   begin
    if (i<>j)and(s[i,j]<>-1) then
     begin
      xx:=z[i].x;
      yy:=z[i].y;
      pp:=z[j].x;
      qq:=z[j].y;
      temp:=0;
      if xx>=pp then temp:=temp+(xx-pp)*(xx-pp);
      if xx<pp then temp:=temp+(pp-xx)*(pp-xx);
      if yy>=qq then temp:=temp+(yy-qq)*(yy-qq);
      if yy<qq then temp:=temp+(qq-yy)*(qq-yy);
      s[i,j]:=sqrt(temp);
     end;
   end;
 end;
temp:=0;
l:=0;
while temp<nn do begin
 min:=99999999;
 for i:=1 to n do begin
  for j:=1 to n do begin
   if (s[i,j]<>-1)and(s[i,j]<min)and((panduan[i]=false)or(panduan[j]=false)) then begin
    min:=s[i,j];
    xx:=i;
    yy:=j;
   end;
  end;
 end;
 l:=l+min;
 temp:=temp+1;
 panduan[xx]:=true;
 panduan[yy]:=true;
end;
writeln(l:0:2);
close(input);
close(output);
End.