标签:des style blog http ar io color os sp
Description
Input
Output
Sample Input
2 1 #. .# 4 4 ...# ..#. .#.. #... -1 -1
Sample Output
2 1
#include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <sstream> #include <queue> #include <typeinfo> #include <fstream> typedef long long ll; using namespace std; //freopen("D.in","r",stdin); //freopen("D.out","w",stdout); #define sspeed ios_base::sync_with_stdio(0);cin.tie(0) #define maxn 10 const int inf=0x7fffffff; //无限大 char board[maxn][maxn]; int place[maxn]; int n,k; int cnt,num; void dfs(int i) { if(k==num) { cnt++; return; } if(i>=n) return; for(int j=0;j<n;j++) { if(!place[j]&&board[i][j]==‘#‘) { place[j]=1; num++; dfs(i+1); place[j]=0; num--; } } dfs(i+1); } int main() { while(cin>>n>>k) { if(n==-1&&k==-1) break; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) cin>>board[i][j]; } memset(place,0,sizeof(place)); cnt=0; num=0; dfs(0); cout<<cnt<<endl; } return 0; }
标签:des style blog http ar io color os sp
原文地址:http://www.cnblogs.com/qscqesze/p/4168437.html