比赛 20101110 评测结果 AWWWWWWWTT
题目名称 奶牛派对 最终得分 10
用户昵称 gragon 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-10 19:37:56
显示代码纯文本
program ex;
var
 f:array [1..1000,1..1000] of longint;
 n,m,x,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]:=maxlongint;
  for u:=1 to n do begin
  read(i,j,k);
  f[i,j]:=k;
  end;
  close(input);
  max:=-1;
end;

procedure ty;
var i,j:longint;
begin
 for i:=1 to n do
  if (f[i,x]<>maxlongint)and(f[x,i]<>maxlongint) then
   if f[i,x]+f[x,i]>max then max:=f[i,x]+f[x,i];
 writeln(max);
 close(output);
end;

begin
  init;
  for k:=1 to n do
  for i:=1 to n do
  for j:=1 to n do
  if (f[i,k]<>maxlongint)and(f[k,j]<>maxlongint) then
  if (f[i,k]+f[k,j]<f[i,j]) then
  f[i,j]:=f[i,k]+f[k,j];
  ty;
end.