比赛 |
20101116 |
评测结果 |
MMMMMMMMMM |
题目名称 |
城市 |
最终得分 |
0 |
用户昵称 |
nick09 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-16 10:22:15 |
显示代码纯文本
const max=99999 ;
var
n,m,u,v,s,i,j,k,a,b,c,ans:longint;
f:array[0..10000]of longint;
t:array[0..10000,0..10000]of longint;
w:array[0..10000,0..10000]of longint;
g:array[0..10000,0..10000]of boolean;
begin
assign(input,'cost.in');reset(input);
assign(output,'cost.out');rewrite(output);
readln(n,m,u,v,s);
for i:=1 to n do readln(f[i]);
for i:=1 to n do
for j:=1 to n do
begin t[i,j]:=f[i];end;
fillchar(g,sizeof(g),false);
for i:=1 to n do
begin readln(a,b,c);t[a,b]:=c;t[b,a]:=c;
g[a,b]:=true;g[b,a]:=true;
end;
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if (t[i,j]>t[i,k]+t[k,j])or(t[i,j]=0) then
begin
t[i,j]:=t[i,k]+t[k,j];t[j,i]:=t[i,k]+t[k,j];
end;
if t[u,v]=0 then begin writeln('-1');close(input);close(output);halt;end;
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if w[i,j]>w[i,k]+w[k,j] then
w[i,j]:=w[i,k]+w[k,j];
writeln(w[u,v]);
close(input);close(output);
end.