| 比赛 | 
    20101110 | 
    评测结果 | 
    AAAAWWWWTT | 
    | 题目名称 | 
    奶牛派对 | 
    最终得分 | 
    40 | 
    | 用户昵称 | 
    1102 | 
    运行时间 | 
    0.000 s  | 
    | 代码语言 | 
    Pascal | 
    内存使用 | 
    0.00 MiB  | 
    | 提交时间 | 
    2010-11-10 20:29:57 | 
显示代码纯文本
program xxxx;
var x,n,m,i,j,k,w,a,b,c,max:longint;
    f:array[1..1000,1..1000] of longint;
begin
  assign(input,'party.in');
  reset(input);
  assign(output,'party.out');
  rewrite(output);
  read(n,m,x);
  max:=maxlongint;
  w:=0;
  for i:=1 to n do
    for j:=1 to n do
      f[i,j]:=max;
  for i:=1 to m do
    begin
      read(a,b,c);
      f[a,b]:=c;
    end;
  for i:=1 to n do
    for j:=1 to n do
      for k:=1 to n do
        if (f[i,j]<max)and(f[j,k]<max) then
          if f[i,j]+f[j,k]<f[i,k] then
            f[i,k]:=f[i,j]+f[j,k];
  for i:=1 to n do
    begin
      if i<>x then
        begin
          m:=f[i,x]+f[x,i];
          if m>w then
            w:=m;
        end;
    end;
  write(w);
  close(input);
  close(output);
end.