0
点赞
收藏
分享

微信扫一扫

HYSBZ 1616(纯深搜)

秀妮_5519 2022-10-25 阅读 122


题目大意:一张图G,有一些障碍物,求路径长度一定(可环)时的路径总数


果断广搜


Program ttd;
var
n,m,t,i,j,k,x1,x2,y1,y2:longint;
s:string;
b:array[0..101,0..101] of boolean;

f:array[0..15,0..101,0..101] of longint;
begin
readln(n,m,t);
fillchar(b,sizeof(b),true);
for i:=1 to n do
begin
readln(s);
for j:=1 to m do if s[j]='*' then b[i,j]:=false;
end;
readln(x1,y1,x2,y2);
fillchar(f,sizeof(f),0);
f[0,x1,y1]:=1;

for k:=1 to t do
begin
for i:=1 to n do
for j:=1 to m do
if f[k-1,i,j]>0 then
begin
if b[i+1,j] then inc(f[k,i+1,j],f[k-1,i,j]);
if b[i-1,j] then inc(f[k,i-1,j],f[k-1,i,j]);
if b[i,j+1] then inc(f[k,i,j+1],f[k-1,i,j]);
if b[i,j-1] then inc(f[k,i,j-1],f[k-1,i,j]);



end;


end;
{
for k:=0 to t do
begin
for i:=1 to n do
begin
for j:=1 to m do
begin
write(f[k,i,j],' ');
end;
writeln;
end;
writeln;
end;
}
writeln(f[t,x2,y2]);


end.



举报

相关推荐

0 条评论