Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
……斜着能走啊?!!!!!fuck#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: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator