| 记录编号 | 
        21503 | 
        评测结果 | 
        AAAAAAAATT | 
    
    
        | 题目名称 | 
        497.奶牛派对 | 
        最终得分 | 
        80 | 
            
    
    
        | 用户昵称 | 
         gragon | 
        是否通过 | 
        未通过 | 
    
    
        | 代码语言 | 
        Pascal | 
        运行时间 | 
        2.832 s  | 
    
    
        | 提交时间 | 
        2010-11-11 08:35:18 | 
        内存使用 | 
        3.93 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		program ex;
var
 f:array [0..1000,0..1000] of longint;
 n,m,x,y,z,max,i,j,k:longint;
procedure init;
var i,j,k,u:longint;
begin
  assign(input,'party.in');
  assign(output,'party.out');
  reset(input);
  rewrite(output);
  readln(n,m,x);
  for i:=1 to n do
  for j:=1 to n do
   f[i,j]:=999999;
  for i:=1 to m do
  begin
    read(y,z);
    readln(f[y,z]);
  end;
  close(input);
end;
begin
  init;
  for k:=1 to n do
  for i:=1 to n do
  for j:=1 to n do
  begin
    begin
      if (f[i,k]+f[k,j]<f[i,j]) then
      f[i,j]:=f[i,k]+f[k,j];
    end;
  end;
  max:=-1;
  for i:=1 to n do
  if i<>x then
  begin
    if max<f[i,x]+f[x,i] then max:=f[i,x]+f[x,i];
  end;
  writeln(max);
  close(output);
end.