比赛 |
20100423 |
评测结果 |
AAAAWWWWWW |
题目名称 |
商人的宣传 |
最终得分 |
40 |
用户昵称 |
ybh |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-04-23 11:14:50 |
显示代码纯文本
program merchant;
var
way:array[0..110,0..110] of boolean;
q,step:array[0..10000] of integer;
n,m,l,i,j,r1,r2,pp,p,ss,tt,t,ans,h:integer;
begin
assign(input,'merchant.in');
reset(input);
assign(output,'merchant.out');
rewrite(output);
readln(n,m,l);
fillchar(way,sizeof(way),false);
for i:=1 to m do
begin
readln(r1,r2);
way[r1,r2]:=true;
end;
readln(pp);
for p:=1 to pp do
begin
readln(ss,tt);
fillchar(q,sizeof(q),0);
ans:=0;
h:=0;
t:=1;
q[1]:=ss;
step[1]:=0;
repeat
h:=h+1;
if step[h]=l then
begin
for j:=h to t do
if q[j]=tt
then inc(ans);
break
end;
i:=q[h];
for j:=1 to n do
begin
if way[i,j] then
begin
t:=t+1;
q[t]:=j;
step[t]:=step[h]+1;
end
end
until h=t;
writeln(ans);
end;
close(input);
close(output)
end.