比赛 |
20091103 |
评测结果 |
AAAAAAAAAA |
题目名称 |
热浪 |
最终得分 |
100 |
用户昵称 |
rottenwood |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-11-03 11:24:40 |
显示代码纯文本
program heatwvx;
var
map:array[1..2500,1..2500] of longint;
q:array[1..10000] of longint;
v:array[1..2500] of boolean;
dist:array[1..2500] of longint;
i,j,k,m,n,h,t,rs,re,ci,x,te,c,ts:longint;
procedure spfa;
begin
fillchar(q,sizeof(q),0); h:=0; t:=0;
fillchar(v,sizeof(v),false);
for i:=1 to n do dist[i]:=maxint;
inc(t); q[t]:=ts; v[ts]:=true;
dist[ts]:=0;
while not(h=t) do
begin
h:=(h mod n)+1;x:=q[h]; v[x]:=false;
for i:=1 to n do
if (map[x,i]>0)and(dist[x]+map[x,i]<dist[i]) then
begin
dist[i]:=dist[x]+map[x,i];
if not(v[i]) then
begin
t:=(t mod n)+1; q[t]:=i;v[i]:=true;
end;
end;
end;
end;
begin
assign(input,'heatwvx.in');reset(input);
assign(output,'heatwvx.out');rewrite(output);
readln(n,c,ts,te);
for i:=1 to c do
begin
readln(rs,re,ci);
map[rs,re]:=ci;
map[re,rs]:=ci;
end;
spfa;
writeln(dist[te]);
close(output);
end.