| 比赛 | 暑假培训B班二测 | 评测结果 | AAAAAA | 
    | 题目名称 | 返回住所 | 最终得分 | 100 | 
    | 用户昵称 | 如烟 | 运行时间 | 0.001 s | 
    | 代码语言 | Pascal | 内存使用 | 0.17 MiB | 
    | 提交时间 | 2012-07-22 11:23:32 | 
显示代码纯文本
const
 t:array[1..4,1..2] of integer=((0,1),(-1,0),(0,-1),(1,0));
var
  i,j,r,c,s,total:longint;
  o:char;
  b:array[0..6,0..6] of integer;
procedure try(x,y,k:integer);
 var
    i:integer;
 begin
  if (x=1)and(y=c)and (k<=s+1)then begin total:=total+1;exit;end;
  if k>s+1 then exit;
  for i:=1 to 4 do
   if (x+t[i,1]>0) and (x+t[i,1]<=r)and
      (y+t[i,2]>0)and (y+t[i,2]<=c)and
       (b[x+t[i,1],y+t[i,2]]=0)then
    begin
    b[x+t[i,1],y+t[i,2]]:=1;
    try(x+t[i,1],y+t[i,2],k+1);
    b[x+t[i,1],y+t[i,2]]:=0;
    end;
end;
begin
 assign(input,'backbarn.in');
 reset(input);
 assign(output,'backbarn.out');
 rewrite(output);
 readln(r,c,s);
 for i:=1 to r do
  begin
  for j:=1 to c do
  begin
   read(o);
   if o='.' then b[i,j]:=0;
   if o='T' then b[i,j]:=1;
  end;
  readln;
  end;
  b[r,1]:=1;
 try(r,1,1);
write(total);
close(input);
close(output);
end.