记录编号 |
22804 |
评测结果 |
AAAAAAAAAA |
题目名称 |
最佳地点 |
最终得分 |
100 |
用户昵称 |
belong.zmx |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.890 s |
提交时间 |
2010-12-27 19:08:03 |
内存使用 |
1.07 MiB |
显示代码纯文本
program beststop(input,output);
var
a:array[1..500,1..500]of longint;
f:array[1..500]of longint;
i,j,k:longint;
p,u,c:longint;
ans,maxn,o:longint;
x,y,q:longint;
begin
assign(input,'bestspot.in');
reset(input);
readln(p,u,c);
for i:=1 to p do
for j:=1 to p do a[i,j]:=maxlongint;
for i:=1 to p do
a[i,i]:=0;
for i:=1 to u do read(f[i]);
for i:=1 to c do
begin
readln(x,y,q);
a[x,y]:=q;
a[y,x]:=q;
end;
close(input);
for k:=1 to p do
for i:=1 to p do
for j:=1 to p do
if (a[i,k]<>maxlongint)and(a[k,j]<>maxlongint) then
if a[i,k]+a[k,j]<a[i,j] then a[i,j]:=a[i,k]+a[k,j];
ans:=maxlongint;
for i:=1 to p do
begin
maxn:=0;
for j:=1 to u do maxn:=maxn+a[i,f[j]];
if maxn<ans then
begin
ans:=maxn;
o:=i;
end;
end;
assign(output,'bestspot.out');
rewrite(output);
writeln(o);
close(output);
end.