图论水题,一个裸的Floyd Warshall再枚举: { Author:wzx961008 Problem:UVa 11015-05-2 Rendezvous Verdict:Accepted Language:PASCAL Run Time:0.012s Submission Date:2011-03-22 12:48:53 } const oo=maxlongint; var graph:array[1..22,1..22]of qword; names:array[1..22]of string; i,j,k,u,v,w,n,m,task,sum,ans,min:longint; begin while true do begin readln(n,m); inc(task); if (n=0)and(m=0) then break; for i:=1 to n do readln(names[i]); for i:=1 to n do for j:=1 to n do graph[i,j]:=oo; for i:=1 to m do begin readln(u,v,w); graph[u,v]:=w; graph[v,u]:=w; end; for i:=1 to n do graph[i,i]:=0; for k:=1 to n do for i:=1 to n do for j:=1 to n do if graph[i,k]+graph[k,j]<graph[i,j] then graph[i,j]:=graph[i,k]+graph[k,j]; min:=oo; for i:=1 to n do begin sum:=0; for j:=1 to n do sum:=sum+graph[i,j]; if sum<min then begin min:=sum; ans:=i; end; end; writeln('Case #',task,' : ',names[ans]); end; end.