比赛 |
20110722 |
评测结果 |
AWAWAWAAAAAAAAAAA |
题目名称 |
网络探测 |
最终得分 |
82 |
用户昵称 |
wo shi 刘畅 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2011-07-22 10:49:21 |
显示代码纯文本
const
oo=maxlongint div 2;
var
n,m,en,i,j,x,y,z:longint;
d,q:array[0..100000]of longint;
v:array[0..100000]of boolean;
g:array[0..1000,0..1000]of longint;
procedure spfa;
var
h,t,x,i:longint;
begin
h:=1;
t:=1;
for i:=0 to n-1 do
begin
v[i]:=false;
d[i]:=oo;
end;
d[0]:=0;
q[1]:=0;
v[0]:=true;
repeat
x:=q[h];
for i:=0 to n-1 do
if d[x]+g[x,i]<d[i] then
begin
d[i]:=d[x]+g[x,i];
if not v[i] then
begin
v[i]:=true;
inc(t);
q[t]:=i;
end;
end;
v[x]:=false;
inc(h);
until h>t;
end;
begin
assign(input,'ping.in'); reset(input);
assign(output,'ping.out'); rewrite(output);
readln(n,m,en);
for i:=0 to n do
for j:=0 to n do
g[i,j]:=oo;
for i:=1 to m do
begin
readln(x,y,z);
g[x,y]:=z;
g[y,x]:=z;
end;
spfa;
if d[en]=oo then writeln('no')
else writeln(d[en]);
close(input);
close(output);
end.