比赛 20110727 评测结果 AAAAAAAAA
题目名称 道路重建 最终得分 100
用户昵称 Yoghurt 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2011-07-27 09:43:01
显示代码纯文本
program rebuild;
const
        filename='rebuild';
        maxn=200;
var
        map,f:array[0..maxn,0..maxn] of longint;
        n,m,d,s,t:longint;

procedure init;
var
        i,x,y,len:longint;
begin
        readln(n);
        readln(m);
        fillchar(f,sizeof(f),10);
        for i:=1 to m do
        begin
                readln(x,y,len);
                map[x,y]:=len;
                map[y,x]:=len;
                f[x,y]:=0;
                f[y,x]:=0;
        end;
        readln(d);
        for i:=1 to d do
        begin
                readln(x,y);
                f[x,y]:=map[x,y];
                f[y,x]:=map[y,x];
        end;
        readln(s,t);
end;

procedure floyed;
var
        i,j,k:longint;
begin
        for k:=1 to n do
        for i:=1 to n do
        for j:=1 to n do
                if (k<>i) and (i<>j) and (k<>j) then
                        if f[i,j]>f[i,k]+f[k,j] then
                                f[i,j]:=f[i,k]+f[k,j];
end;

begin
        assign(input,filename+'.in'); reset(input);
        assign(output,filename+'.out'); rewrite(output);

        init;
        floyed;
        writeln(f[s,t]);

        close(input); close(output);
end.