比赛 |
20110722 |
评测结果 |
AWAAAAAAAAEEAAAEE |
题目名称 |
网络探测 |
最终得分 |
70 |
用户昵称 |
WSJZX |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2011-07-22 11:39:51 |
显示代码纯文本
program ping;
type
arry=record
s,next:longint;
end;
erry=record
y,v,next:longint;
end;
var
i,j,n,m,t,ans,te,tn,k,min,x,y,v,c,s,oo:longint;
a:array[1..10000] of arry;
e:array[1..10000] of erry;
q:array[1..10000] of longint;
flag:array[1..10000] of boolean;
dis:array[1..10000] of longint;
pre:array[1..10000] of longint;
procedure insert(x,y,v:longint);
begin
inc(t);
e[t].y:=y;
e[t].v:=v;
e[t].next:=a[x].next;
a[x].next:=t;
inc(a[x].s);
end;
procedure spfa;
var
i,j,head,tail,t:longint;
begin
fillchar(q,sizeof(q),0);
fillchar(flag,sizeof(flag),false);
fillchar(dis,sizeof(dis),$7f);
oo:=dis[1];
q[1]:=1;
flag[1]:=true;
head:=1;
tail:=1;
dis[1]:=0;
pre[1]:=0;
while head<=tail do
begin
t:=q[head];
te:=a[t].next;
for i:=1 to a[t].s do
begin
tn:=e[te].y;
if dis[tn]>dis[t]+e[te].v then
begin
dis[tn]:=dis[t]+e[te].v;
pre[tn]:=t;
if not(flag[tn]) then
begin
flag[tn]:=true;
inc(tail);
q[tail]:=tn;
end;
end;
te:=e[te].next;
end;
flag[t]:=false;
inc(head);
end;
end;
procedure find(s:longint);
var
i,j:longint;
begin
if s=0 then exit
else inc(ans);
find(pre[s]);
end;
begin
assign(input,'ping.in');reset(input);
assign(output,'ping.out');rewrite(output);
readln(n,m,s);
for i:=1 to m do
begin
readln(x,y,v);
insert(x+1,y+1,v);
insert(y+1,x+1,v);
end;
spfa;
s:=s+1;
find(s);
if ans>10 then writeln('no')
else if dis[s]=oo then writeln('no')
else writeln(dis[s]);
close(input);close(output);
end.