记录编号 190787 评测结果 AAAAAAAA
题目名称 服务点设置 最终得分 100
用户昵称 GravatarVacaTionGOD 是否通过 通过
代码语言 Pascal 运行时间 0.000 s
提交时间 2015-10-04 15:52:04 内存使用 0.00 MiB
显示代码纯文本
var
 d:array[0..100,0..100] of longint;
 n,m,i,j,k,a,b,w:longint;
procedure init;
begin
 readln(n,m);
  for i:=0 to n-1 do
   for j:=0 to n-1 do
    if i=j  then d[i,j]:=0 else d[i,j]:=maxint div 2;
  for i:=1 to m do
   begin
     readln(a,b,w);
     d[a,b]:=w;  d[b,a]:=w;
   end;
end;
procedure floyed;
begin
 for k:=0 to n-1 do
  for i:=0 to n-1 do
   for j:=0 to n-1 do
    if d[i,k]+d[k,j]<d[i,j] then
      d[i,j]:=d[i,k]+d[k,j];
    end;
procedure sort;
var max:array[0..100] of longint;
    min,ans:longint;
begin
 min:=maxlongint;
 fillchar(max,sizeof(max),0);
 for i:=0 to n-1 do
  for j:=0 to n-1 do
   if d[i,j]>max[i] then max[i]:=d[i,j];
  for i:=0 to n-1 do
   if max[i]<min then begin min:=max[i]; ans:=i; end;
  writeln(ans);
end;
begin
assign(input,'djsa.in');
reset(input);
assign(output,'djsa.out');
rewrite(output);
 init;
 floyed;
 sort;
close(input);
close(output);
end.

var
  i,j,n,m,a,b,c,k:integer;
  max,min:longint;
  d:array[0..100,0..100] of longint;
begin
  readln(n,m);
  for i:=0 to n-1 do
    for j:=0 to n-1 do
      if i=j then d[i,j]:=0
        else d[i,j]:=maxlongint div 2;
  for i:=1 to m do
    begin
      readln(a,b,c);
      d[a,b]:=c; d[b,a]:=c;
    end;
  for k:=0 to n-1 do
    for i:=0 to n-1 do
      for j:=0 to n-1 do
        if d[i,j]>d[i,k]+d[k,j] then
          d[i,j]:=d[i,k]+d[k,j];
  min:=maxlongint;

  for i:=0 to n-1 do
    begin
      max:=0;
      for j:=0 to n-1 do
        if d[i,j]>max then
          max:=d[i,j];
      if max<min then
        begin
          min:=max;
          b:=i;
        end;
    end;
  writeln(b);
end.