记录编号 |
22791 |
评测结果 |
AAAAAAAAAA |
题目名称 |
最佳地点 |
最终得分 |
100 |
用户昵称 |
wo shi 刘畅 |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.782 s |
提交时间 |
2010-12-26 21:07:27 |
内存使用 |
1.07 MiB |
显示代码纯文本
const
oo=999999999;
var
total,n,j,m,i,p,now,min:longint;
b:array[0..500]of longint;
g:array[0..500,0..500]of longint;
procedure init;
var
i,x,y,j:longint;
begin
assign(input,'bestspot.in'); reset(input);
assign(output,'bestspot.out'); rewrite(output);
readln(n,m,p);
for i:=1 to m do readln(b[i]);
for i:=1 to n do
for j:=1 to n do
g[i,j]:=oo;
for i:=1 to p do
begin
readln(x,y,g[x,y]);
g[y,x]:=g[x,y];
end;
end;
procedure floyd;
var
i,j,k:longint;
begin
for k:=1 to n do
for i:=1 to n do
if (i<>k)and(g[i,k]<oo) then
for j:=1 to n do
if (i<>j)and(k<>j) then
if g[i,k]+g[k,j]<g[i,j] then
g[i,j]:=g[i,k]+g[k,j];
for i:=1 to n do g[i,i]:=0;
end;
begin
init;
floyd;
min:=oo;
for i:=1 to n do
begin
total:=0;
for j:=1 to m do
inc(total,g[i,b[j]]);
if total<min then
begin
min:=total;
now:=i;
end;
end;
writeln(now);
close(input);
close(output);
end.