标签:
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 28733 | Accepted: 14220 |
Description
Input
Output
Sample Input
2 1 #. .# 4 4 ...# ..#. .#.. #... -1 -1
Sample Output
2 1
好题
/* *********************************************** Author :pk29 Created Time :2015/8/19 18:14:35 File Name :4.cpp ************************************************ */ #include <iostream> #include <cstring> #include <cstdlib> #include <stdio.h> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <math.h> #include <stdlib.h> #include <iomanip> #include <list> #include <deque> #include <stack> #define ull unsigned long long #define ll long long #define mod 90001 #define INF 0x3f3f3f3f #define maxn 10000+10 #define cle(a) memset(a,0,sizeof(a)) const ull inf = 1LL << 61; const double eps=1e-5; using namespace std; bool cmp(int a,int b){ return a>b; } char mp[20][20]; int vc[10]; int n,k,num=0; void dfs(int row,int cnt){ if(cnt==k){ num++;return ; } if(row>n)return ; for(int i=1;i<=n;i++){ if(!vc[i]&&mp[row][i]==‘#‘){ vc[i]=1; dfs(row+1,cnt+1); vc[i]=0; } } dfs(row+1,cnt); return ; } int main() { #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif //freopen("out.txt","w",stdout); while(cin>>n>>k){ if(n==-1&&k==-1)break; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++){ cin>>mp[i][j]; } num=0; cle(vc); dfs(1,0); printf("%d\n",num); } return 0; }
标签:
原文地址:http://www.cnblogs.com/pk28/p/4743073.html