标签:
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 24850 | Accepted: 12290 |
Description
Input
Output
Sample Input
2 1 #. .# 4 4 ...# ..#. .#.. #... -1 -1
Sample Output
2 1
Source
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<cmath> #include<string> using namespace std; int n,k,ans; char s[10][10]; bool vis[10]; void dfs(int x,int num) { if(num==k) { ans++; return ; } if(x==n) return ; for(int i=0;i<n;i++) { if(s[x][i]==‘#‘&&!vis[i]) { vis[i]=1; dfs(x+1,num+1); vis[i]=0; } } dfs(x+1,num); return ; } int main() { while(scanf("%d%d",&n,&k)!=EOF) { ans=0; if(n==-1&&k==-1) break; memset(vis,0,sizeof(vis)); for(int i=0;i<n;i++) scanf("%s",s[i]); dfs(0,0); printf("%d\n",ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/a972290869/p/4338787.html