POJ1125

题意:对于一个点i,设f(i)=max{mindis[i,j]} (j≠i).

其中mindis是各个点对之间的最短路.求min{f(i)} (1<=i<=n).

分析:floyd求出最短路即可.

code:

var   person,time,n,i,j,k,p,min,max,mini,minperson:longint;
      map:array[0..110,0..110] of longint;
      f:boolean;



begin

      readln(n);
      while n<>0 do
      begin
            fillchar(map,sizeof(map),1);
            for i:=1 to n do
            begin
                  read(p);
                  for j:=1 to p do
                  begin
                        read(person,time);
                        map[i,person]:=time;
                  end;
                  readln;
            end;

            for k:=1 to n do
               for i:=1 to n do
                  for j:=1 to n do
                  if map[i,k]+map[k,j]<map[i,j] then
                  map[i,j]:=map[i,k]+map[k,j];



            min:=maxlongint;
            for i:=1 to n do
            begin
                  max:=-maxlongint;
                  f:=true;
                  for j:=1 to n do
                  begin
                        if i=j then continue;
                        if map[i,j]=16843009 then
                        begin f:=false; break; end;
                        if map[i,j]>max then max:=map[i,j];
                  end;

                  if f then
                    if max<min then
                    begin min:=max; minperson:=i; end;
            end;

            writeln(minperson,' ',min);
            readln(n);
      end;
end.

转载于:https://www.cnblogs.com/exponent/archive/2011/08/10/2133561.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值