比赛 |
暑假培训B班二测 |
评测结果 |
AAAAAA |
题目名称 |
返回住所 |
最终得分 |
100 |
用户昵称 |
李振文 |
运行时间 |
0.001 s |
代码语言 |
Pascal |
内存使用 |
0.21 MiB |
提交时间 |
2012-07-22 11:22:51 |
显示代码纯文本
program x;
var
r,c,k,i,j,max:longint;
a:array[0..100,0..100]of integer;
s:array[0..100,0..100]of char;
f:array[0..100,0..100]of integer;
//--------------------------------------//
procedure ff(x,y,z:longint);
var
i,j:longint;
begin
if (z<=k)and(x=1)and(y=c) then inc(max);
if z<k then
begin
for i:=x-1 to x+1 do
for j:=y-1 to y+1 do
if ((i=x)or(j=y))and((i<>x)or(j<>y))and(s[i,j]='.')
and((z+f[i,j])<=k)and(a[i,j]=0)
then
begin
a[i,j]:=1;
ff(i,j,z+1);
a[i,j]:=0;
end;
end;
end;
//----------------------------------------//
begin
assign(input,'backbarn.in');
reset(input);
assign(output,'backbarn.out');
rewrite(output);
readln(r,c,k);
fillchar(a,sizeof(a),0);
for i:=1 to r do
begin
for j:=1 to c do
read(s[i,j]);
readln;
end;
f[1,c-1]:=2;
f[2,c]:=2;
for i:=1 to r do
for j:=c downto 1 do
if (f[i,j]<>2)and((i<>1)or(j<>r)) then
begin
if (s[i-1,j]='.')and(i>1)then f[i,j]:=f[i-1,j]+1;
if (s[i,j+1]='.')and(((i>1)and(s[i-1,j]>s[i,j+1]))or(i<=1)) and(j<c)
then f[i,j]:=f[i,j+1]+1;
end;
a[r,1]:=1;
ff(r,1,1);
writeln(max);
close(input);
close(output);
end.