记录编号 |
26812 |
评测结果 |
AAAAAAAAA |
题目名称 |
道路重建 |
最终得分 |
100 |
用户昵称 |
reamb |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.032 s |
提交时间 |
2011-07-27 14:41:41 |
内存使用 |
4.88 MiB |
显示代码纯文本
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.