| 比赛 | 暑假培训B班二测 | 评测结果 | AAAAAA | 
    | 题目名称 | 返回住所 | 最终得分 | 100 | 
    | 用户昵称 | Citron酱 | 运行时间 | 0.001 s | 
    | 代码语言 | C++ | 内存使用 | 0.29 MiB | 
    | 提交时间 | 2012-07-22 09:41:21 | 
显示代码纯文本
#include <cstdio>
#define I_F "backbarn.in"
#define O_F "backbarn.out"
const short MAXn=5+2;
const short R[4][2]={		 { 1, 0},
					 { 0,-1},		 { 0, 1},
					 		 {-1, 0}};
short n,m,k,ans=0;
bool map[MAXn][MAXn]={{false}};
void Input();
void Dfs(const short&, const short&, const short&);
void Output();
int main()
{
	Input();
	Dfs(1,1,1);
	Output();
	return 0;
}
void Input()
{
	freopen(I_F,"r",stdin);
	scanf("%hd%hd%hd",&n,&m,&k);
	char t;
	for (short i=n; i>0; --i)
	{
		scanf("%*c");
		for (short j=1; j<=m; ++j)
		{
			scanf("%c",&t);
			map[i][j]=(t=='.')?true:false;
		}
	}
}
void Dfs(const short &x, const short &y, const short &j)
{
	if (x==n && y==m)
		++ans;
	else
		if (n+m-x-y<=k-j)
		{
			map[x][y]=false;
			for (short i=0; i<4; ++i)
				if (map[x+R[i][0]][y+R[i][1]])
					Dfs(x+R[i][0], y+R[i][1],j+1);
			map[x][y]=true;
		}
}
void Output()
{
	freopen(O_F,"w",stdout);
	printf("%hd\n",ans);
}