比赛 |
20110727 |
评测结果 |
AAAAAAAAA |
题目名称 |
道路重建 |
最终得分 |
100 |
用户昵称 |
reamb |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2011-07-27 10:22:08 |
显示代码纯文本
program daluchongjian;
var
a,b,c,d,k,i,j,x,y,n,m:longint;
map:array[1..1000,1..1000]of longint;
bz:array[1..1000,1..1000]of boolean;
begin
assign (input,'rebuild.in');
reset(input);
assign (output,'rebuild.out');
rewrite (output);
readln (n);
readln (m);
for i:=1 to n do
for j:=1 to n do
map[i,j]:=maxlongint;
for i:=1 to n do
for j:=1 to n do
bz[i,j]:=false;
for i:=1 to m do
begin
readln (a,b,c);
bz[a,b]:=true;
bz[b,a]:=true;
map[a,b]:=c;
map[b,a]:=c
end;
readln (d);
for i:=1 to d do
begin
readln (a,b);
bz[a,b]:=false;
bz[b,a]:=false
end;
for i:=1 to n do
for j:=1 to n do
if bz[i,j] then
map[i,j]:=0;
readln (x,y);
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if (map[i,k]<>maxlongint)and(map[k,j]<>maxlongint)
and(map[i,k]+map[k,j]<map[i,j]) then
map[i,j]:=map[i,k]+map[k,j];
writeln (map[x,y]);
close (input);
close (output)
end.