标签:
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 37432 | Accepted: 18402 |
Description
Input
Output
Sample Input
2 1 #. .# 4 4 ...# ..#. .#.. #... -1 -1
Sample Output
2 1
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 6 int n,k,ans; 7 bool vis[15]; 8 char mat[15][15]; 9 10 void dfs(int a,int b) 11 { 12 if(b==k) 13 { 14 ans++; 15 return; 16 } 17 if(a>n) return; 18 for(int i=0;i<n;i++) 19 if(mat[a][i]==‘#‘&&!vis[i]) 20 { 21 vis[i]=1; 22 dfs(a+1,b+1); 23 vis[i]=0; 24 } 25 dfs(a+1,b); 26 } 27 28 int main() 29 { 30 while(scanf("%d %d",&n,&k)&&n!=-1&&k!=-1) 31 { 32 for(int i=1;i<=n;i++) 33 scanf("%s",mat[i]); 34 ans=0; 35 memset(vis,0,sizeof(vis)); 36 dfs(1,0); 37 printf("%d\n",ans); 38 } 39 return 0; 40 }
标签:
原文地址:http://www.cnblogs.com/InWILL/p/5982205.html