比赛 20091111 评测结果 ATAAAAAATT
题目名称 建造路径 最终得分 70
用户昵称 い夢£神话︷ 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-11-11 10:58:35
显示代码纯文本
program aa;
var
        tu:array[1..1000,1..1000]of double;
        use:array[1..1000]of boolean;
        t:text;
        loop,loop1,n,m,a,b:longint;
        sum:integer;
        a1:array[1..1000]of integer;
        zuo:array[1..1000,1..2]of double;
        ans,min:double;
begin
        ans:=0;
        assign(t,'roads.in');
        reset(t);
        readln(t,n,m);
        for loop:=1 to n do
                readln(t,zuo[loop,1],zuo[loop,2]);
        for loop:=1 to n do
                for loop1:=1 to n do
                         tu[loop,loop1]:=sqrt(sqr(zuo[loop,1]-zuo[loop1,1])
                         +sqr(zuo[loop,2]-zuo[loop1,2]));
        for loop:=1 to m do
        begin
                readln(t,a,b);
                tu[a,b]:=0;
                tu[b,a]:=0;
        end;
        close(t);
        sum:=1;
        use[1]:=true;
        a1[1]:=1;
        a:=0;
        repeat
                min:=30000000000000;

                for loop:=1 to sum do
                begin
                        for loop1:=1 to n do
                        begin
                                if not use[loop1] then
                                        if tu[a1[loop],loop1]<min then
                                        begin
                                                min:=tu[a1[loop],loop1];
                                                a:=loop1;
                        end;            end;
                end;
                use[a]:=true;
                ans:=ans+min;
                sum:=sum+1;
                a1[sum]:=a;
        until sum=n;
        assign(t,'roads.out');
        rewrite(t);
        writeln(t,ans:0:2);
        close(t);

end.