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 WindHarry at 2010-04-11 20:56:26 on Problem 1125
var a:array[1..100,1..100]of longint;
    b:array[1..100]of boolean;
    i,j,x,y,n,k,count,min,max:longint;

begin


       while true do begin
        readln(n); if n=0 then break;
        fillchar(a,sizeof(a),$7f);
        for i:=1 to n do begin
         read(k);
         for j:=1 to k do begin
          read(x,y);
          a[i,x]:=y;
         end;
        end;
        for k:=1 to n do
         for i:=1 to n do
          for j:=1 to n do
           if a[i,k]<a[i,j]-a[k,j] then a[i,j]:=a[i,k]+a[k,j];
        count:=0; fillchar(b,sizeof(b),0);
        min:=maxlongint shr 3;
        for i:=1 to n do begin
         max:=-1;
         for j:=1 to n do
          if (i<>j) and (a[i,j]>max) then max:=a[i,j];
         if max<min then begin min:=max; k:=i; end;
        end;
        if k>100000000
         then writeln('disjoint')
         else writeln(k,' ',min);
       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