比赛 20091103 评测结果 AAAAAAAAAA
题目名称 热浪 最终得分 100
用户昵称 打不死的羊 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-11-03 10:46:19
显示代码纯文本
program heatwvx;
type
fxz1=array[1..2500,1..2500] of longint;
fxz2=array[1..2500] of boolean;
var
f1,f2:text;
i,j,n,m,t,w,p,x,y,minn,min:longint;
map:fxz1;
flag:fxz2;
begin assign(f1,'heatwvx.in');
      assign(f2,'heatwvx.out');
      reset(f1);rewrite(f2);
      readln(f1,n,m,t,w);
      for i:=1 to n do
      for j:=1 to n do map[i,j]:=-1;
      for i:=1 to m do begin readln(f1,x,y,p);
                             map[x,y]:=p;
                             map[y,x]:=p;
                        end;
      for i:=1 to n do flag[i]:=true;
      flag[t]:=false;
      for p:=2 to n do
      begin min:=maxlongint;
            for i:=1 to n do
            if (t<>i)and(map[t,i]<min)and(flag[i])and(map[t,i]>=0) then
            begin min:=map[t,i];
                  minn:=i;
            end;
            flag[minn]:=false;
            for j:=1 to n do
            if (j<>minn)and(j<>t)and((map[t,minn]+map[minn,j]<map[t,j])or(map[t,j]=-1))and(map[t,minn]>-0)and(map[minn,j]>-1)and(flag[j]) then
            map[t,j]:=map[t,minn]+map[minn,j];

      end;
      writeln(f2,map[t,w]);
      close(f1);close(f2);
end.