比赛 |
20091111 |
评测结果 |
AEWWWWWEEE |
题目名称 |
建造路径 |
最终得分 |
10 |
用户昵称 |
bing |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-11-11 11:18:58 |
显示代码纯文本
program bing;
type
sb=record
x,y:longint;
end;
var
f1,f2:text;
n,m:integer;
ans:real;
a:array[1..1000] of sb;
b:array[1..1000,1..1000] of boolean;
l:array[1..1000,1..1000] of real;
procedure init;
var
i,j,c,d:integer;
begin
assign(f1,'roads.in');reset(f1);
assign(f2,'roads.out');rewrite(f2);
readln(f1,n,m);
fillchar(b,sizeof(b),false);
for i:=1 to n do readln(f1,a[i].x,a[i].y);
for i:=1 to n-1 do
for j:=i+1 to n do
begin
l[i,j]:=sqrt(sqr(a[i].x-a[j].x)+sqr(a[i].y-a[j].y));
l[j,i]:=l[i,j];
end;
for i:=1 to m do
begin
readln(f1,c,d);
b[c,d]:=true;
b[d,c]:=true;
end;
ans:=0;
end;
procedure nb;
var
i,j,k,h,t,ht,tt:integer;
f:boolean;
min:real;
q:array[1..1001] of integer;
begin
q[1]:=1;
h:=1;t:=1;
repeat
f:=false; min:=10000000;
ht:=t+1;tt:=t;
for i:=h to t do
begin
for j:=1 to n do
begin
if (q[i]<>j)and(l[q[i],j]<min) then
begin min:=l[q[i],j];
if (not(b[q[i],j]))and(tt<n) then
begin
inc(tt);q[tt]:=j;f:=true;end;
end;
if (b[q[i],j])and(tt<n) then begin inc(tt);q[tt]:=j;end;
end;
end;
if f then ans:=ans+min;
h:=ht;t:=tt;
until h>t;
end;
begin
init;
nb;
writeln(f2,ans:0:2);
close(f1);close(f2);
end.