比赛 20121030 评测结果 EEEEEEEEEE
题目名称 逃离遗迹 最终得分 0
用户昵称 舍得 运行时间 0.001 s
代码语言 Pascal 内存使用 3.98 MiB
提交时间 2012-10-30 20:46:59
显示代码纯文本
const maxn=1000;
var
    map:array[1..maxn,1..maxn]of longint;
    i,j,m,n:longint;
    a,b,c,x,y,z,k,sum,jj:longint;

function min(i,j:longint):longint;
begin
  if i<j then exit(i) else exit(j);
end;


begin
  assign(input,'escapeb.in');
  reset(input);
  assign(output,'escapeb.out');
  reset(output);
  readln(n,a,b,c);
  fillword(map,sizeof(map)>>2,10000);
  for i:=1 to n-1 do
    begin
    map[i,i]:=0;
    readln(x,y,z);
    if z<map[x,y] then
      begin
      map[x,y]:=z;
      map[y,x]:=z;
      end;
    end;
  for k:=1 to n do
  for i:=1 to n do
  for j:=1 to n do
  if (k<>i) and (k<>j) and (i<>j) then
    begin
    map[i,j]:=min(map[i,j],map[i,k]+map[k,j]);
    end;
  sum:=maxlongint;
  for i:=1 to n do
    begin
    if map[i,a]+map[i,b]+map[i,c]<sum
    then
      begin
      jj:=i;
      sum:=map[i,a]+map[i,b]+map[i,c];
      end;
    end;
  writeln(jj);
  writeln(sum);
  close(input);
  close(output);
end.