Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## ……斜着能走啊？！！！！！fuck

Posted by 18357 at 2014-08-10 22:10:02 on Problem 1321
```#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 20
using namespace std;

int map[N][N],n,m,ans;
int a[N]/*,b[N],c[N]*/;

void dfs(int f,int x,int y)
{
int i,j;
if(a[y]/*||b[x+y]||c[x-y+n]*/||map[x][y])return ;
if(f==m)
{
ans++;
return ;
}
a[y]++;
//	b[x+y]++;
//	c[x-y+n]++;
for(i=x+1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
dfs(f+1,i,j);
}
}
a[y]--;
//	b[x+y]--;
//	c[x-y+n]--;
}

int main()
{
int i,j,k;
char t[N];
while(scanf("%d%d",&n,&m),n+1)
{
memset(a,0,sizeof(a));
//		memset(b,0,sizeof(b));
//		memset(c,0,sizeof(c));
ans=0;
for(i=1;i<=n;i++)
{
scanf("%s",t+1);
for(j=1;j<=n;j++)
{
k=(t[j]=='#'?0:1);
map[i][j]=k;
}
}
for(i=1;i<=n-m+1;i++)
{
for(j=1;j<=n;j++)
{
dfs(1,i,j);
}
}
printf("%d\n",ans);
}
return 0;
}
```

Followed by: