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水过!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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator