Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
FLOYD水过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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator