比赛 20101116 评测结果 WWEEEEEEEW
题目名称 城市 最终得分 0
用户昵称 sr-end 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-16 10:27:26
显示代码纯文本
program aa;
var
a,b,c:integer;
br:array[1..100,1..3] of integer;
ar:array[1..100,1..3] of integer;
i,j,x:integer;
n,m,u,v,s:integer;
q:array[1..100] of integer;
f1,f2:text;
procedure floyd;
var
x,i,j:integer;
begin
 for x:=1 to n do
  for i:=1 to n do
    for j:=1 to n do
     if ((ar[i,j]>ar[i,x]+ar[x,j])or (ar[i,j]=0))
     and (ar[i,x]<>0) and (ar[x,j]<>0)and(i<>j)
     then
     ar[i,j]:=ar[i,x]+ar[x,j];
end;
procedure sun;
var
i,j,k:integer;
begin
for k:=1 to n do
  for i:=1 to n do
   for j:=1 to n do
      if (ar[i,k]+ar[k,j]<s)and(ar[i,k]<>0)and(ar[k,j]<>0) then
       begin
       if ((br[i,j]>br[i,k]+ar[k,j])or (br[i,j]=0))
     and (br[i,k]<>0) and (br[k,j]<>0)and(i<>j)
     then
     br[i,j]:=br[i,k]+br[k,j];
       end;
end;
begin
assign(f1,'cost.in'); assign(f2,'cost.out');
reset(f1);rewrite(f2);
readln(f1,n,m,u,v,s);
for i:=1 to n do
readln(f1,q[i]);
for i:=1 to m do
begin
  readln(f1,a,b,c);
  ar[a,b]:=c;
  ar[b,a]:=c;
  br[a,b]:=q[i];
  br[b,a]:=q[i];
  end;
 floyd;
 if ar[u,v]>s then write(f2,'-1')
   else
   begin
    sun;
    write(f2,br[u,v]);
    end;

    close(f1);close(f2);


end.