| 比赛 | 
    20110722 | 
    评测结果 | 
    AWAWAAWWAWWWWWWWW | 
    | 题目名称 | 
    网络探测 | 
    最终得分 | 
    29 | 
    | 用户昵称 | 
    Oo湼鞶oO | 
    运行时间 | 
    0.000 s  | 
    | 代码语言 | 
    Pascal | 
    内存使用 | 
    0.00 MiB  | 
    | 提交时间 | 
    2011-07-22 08:58:09 | 
显示代码纯文本
const
mm=200000000;
var
map,v:array[0..1100,0..1100]of longint;
num,dist,d:array[0..1100]of longint;
n,m,x,y,c,i,j,arm:longint;
f:array[0..1100]of boolean;
procedure add(x,y,c:longint);
begin
    inc(num[x]);map[x,num[x]]:=y;v[x,num[x]]:=c;
end;
procedure djs(s,a:longint);
var
i,j,h,t,x,y:longint;
begin
    for i:=0 to n do dist[i]:=mm;
    dist[s]:=0;
    t:=1;h:=0;d[1]:=s;f[s]:=true;
    while h<>t do begin
        inc(h);x:=d[h];f[x]:=false;
        for i:=1 to num[x] do begin
            y:=map[x,i];
            if dist[y]>dist[x]+v[x,i] then begin
                dist[y]:=dist[x]+v[x,i];
                if not f[y] then begin
                    inc(t);d[t]:=y;
                end;
            end;
        end;
    end;
end;
begin
assign(input,'ping.in');
assign(output,'ping.out');
reset(input);
rewrite(output);
    read(n,m,arm);dec(n);
    for i:=0 to n do
        for j:=0 to n do map[i,j]:=mm;
    for i:=0 to n do begin
        read(x,y,c);
        add(x,y,c);add(x,y,c);
    end;
    djs(0,arm);
    if dist[arm]<>mm then
        writeln(dist[arm])
    else writeln('no');
close(input);close(output);
end.