比赛 |
20091111 |
评测结果 |
AEAAAAAEEE |
题目名称 |
建造路径 |
最终得分 |
60 |
用户昵称 |
rottenwood |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-11-11 09:52:19 |
显示代码纯文本
program roads;
var
map:array[1..1000,1..1000] of real;
i,j,k,m,n,v0:longint;
ans:double;
x,y:array[1..1000] of longint;
procedure prim;
var
lowcost:array[1..4000] of real;
i,j,k:longint; min:real;
begin
for i:=1 to n do begin
lowcost[i]:=map[v0,i];
end;
for i:=1 to n-1 do
begin
min:=maxlongint;
for j:=1 to n do
if (lowcost[j]<min)and(lowcost[j]<>-1) then begin
min:=lowcost[j]; k:=j;
end;
ans:=ans+lowcost[k];
lowcost[k]:=0;
for j:=1 to n do
if map[k,j]<lowcost[j] then begin
lowcost[j]:=map[k,j];
end;
end;
end;
begin
assign(input,'roads.in');reset(input);
assign(output,'roads.out');rewrite(output);
readln(n,m);
for i:=1 to n do
readln(x[i],y[i]);
for i:=1 to n do
for j:=1 to n do map[i,j]:=-1;
for i:=1 to n-1 do
for j:=i+1 to n do
begin
map[i,j]:=sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j]));
map[j,i]:=map[i,j];
end;
for i:=1 to m do
begin
readln(j,k);
map[j,k]:=0;
map[k,j]:=0;
end;
v0:=1;
prim;
writeln(ans:0:2);
close(output);
end.