标签:区别 结束 stdio.h std auth ios last res char
Input
Output
Sample Input
2 1 #. .# 4 4 ...# ..#. .#.. #... -1 -1
Sample Output
2 1
/* * @Author: lyuc * @Date: 2017-05-02 16:51:45 * @Last Modified by: lyuc * @Last Modified time: 2017-05-02 17:07:23 */ #include <iostream> #include <stdio.h> #include <string.h> #define LL long long using namespace std; int n,k; char mapn[10][10]; int col[10]; LL res=0; void dfs(int u,int co){//遍历到第几行 if(co==k){ res++; return ; } if(u>=n) return ; for(int i=0;i<n;i++){ if(col[i]) continue; if(mapn[u][i]==‘#‘){ col[i]=1; dfs(u+1,co+1); col[i]=0; } } dfs(u+1,co); } void init(){ memset(col,0,sizeof col); res=0; } int main(){ // freopen("in.txt","r",stdin); while(scanf("%d%d",&n,&k)!=EOF&&(n!=-1&&k!=-1)){ init(); for(int i=0;i<n;i++) scanf("%s",mapn[i]); dfs(0,0); printf("%lld\n",res); } return 0; }
标签:区别 结束 stdio.h std auth ios last res char
原文地址:http://www.cnblogs.com/wuwangchuxin0924/p/6797066.html