- 最短路上的统计
- 2009-08-03 10:57:00 @
program sdajkf;
var
n,m,i,j,k,l,o,p,w:longint;
a,b:array[0..10000]of longint;
dp,c:array[0..7000,0..7000]of longint;
begin
readln(n,m);
for i:=1 to n do
for j:=1 to n do
dp:=100000;
i:=0;
repeat
inc(i);
readln(a[i],b[i]);
dp[a[i],b[i]]:=1; c[a[i],b[i]]:=2;
inc(i);
a[i]:=b; b[i]:=a;
dp[a[i],b[i]]:=1; c[a[i],b[i]]:=2;
until i=2*m;
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
begin
if dp=dp+dp[k,j] then c:=c+c+c[k,j]-3
else if dp>dp+dp[k,j] then begin
dp:=dp+dp[k,j];
c:=c+c[k,j]-1;
end;
end;
readln(p);
for i:=1 to p do
begin
readln(l,o);
writeln(c[l,o]);
end;
end.
0 条评论
目前还没有评论...