比赛 |
20091111 |
评测结果 |
AEAAAAAEEE |
题目名称 |
建造路径 |
最终得分 |
60 |
用户昵称 |
EnAsn |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-11-11 10:41:51 |
显示代码纯文本
program ex;
type
ss=array[1..1000,1..1000]of real;
data=record
x,y:longint;
end;
sz=array[1..1000]of data;
var
map:ss;
f:sz;
n,m:integer;
procedure init;
var
i,j,a,b:integer;
begin
assign(input,'roads.in');
assign(output,'roads.out');
reset(input);
rewrite(output);
readln(n,m);
for i:=1 to n do readln(f[i].x,f[i].y);
for i:=1 to n-1 do
for j:=i+1 to n do
begin
map[i,j]:=sqrt(sqr(f[i].x-f[j].x)+sqr(f[i].y-f[j].y));
map[j,i]:=map[i,j];
end;
for i:=1 to n do map[i,i]:=0;
for i:=1 to m do
begin
readln(a,b);
map[a,b]:=0;
map[b,a]:=0;
end;
end;
procedure main;
var
i,j,k,k1,k2:integer;
tail:integer;
flag:array[1..1000]of boolean;
que:array[0..1000]of integer;
min,sum:real;
begin
fillchar(flag,sizeof(flag),true);
fillchar(que,sizeof(que),0);
flag[1]:=false;
que[0]:=1;que[1]:=1;
sum:=0;
for i:=1 to n-1 do
begin
min:=99999999;
for j:=1 to que[0] do
for k:=1 to n do
if flag[k] then
if map[que[j],k]<min then
begin
min:=map[que[j],k];
k1:=k;
end;
sum:=sum+min;
inc(que[0]);
que[que[0]]:=k1;
flag[k1]:=false;
end;
writeln(sum:0:2);
close(output);
end;
begin
init;
main;
end.