Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

饿,floyd水过!

Posted by lijiaming456 at 2011-09-18 17:43:27 on Problem 1125
program ss;
var dist:array[1..100,1..100] of longint;
    i,j,k,m,n,s,t,ans,x,y,z,max:longint;

begin
while true do
      begin
      readln(n);
      if n=0 then halt;
      for i:=1 to n do
          for j:=1 to n do dist[i,j]:=1000000000;
      for i:=1 to n do
          begin
          read(x);
          for j:=1 to x do
              begin
              read(y,z); dist[i,y]:=z;
              end;
          readln;
          end;
      for k:=1 to n do
          for i:=1 to n do
              if i<>k then
                 for j:=1 to n do
                     if (i<>j) and (j<>k) and (dist[i,j]>dist[i,k]+dist[k,j]) then
                        dist[i,j]:=dist[i,k]+dist[k,j];
      ans:=1000000000;
      for i:=1 to n do
          begin
          max:=0;
          for j:=1 to n do
              if (i<>j) and (dist[i,j]>max) then max:=dist[i,j];
          if max<ans then begin ans:=max; k:=i; end;
          end;
      writeln(k,' ',ans);
      end;
end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator