记录一个菜逼的成长。。
之前搜索的题目接触的少。。现在多练练。。
这题的搜索很经典。
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <cctype>
#include <bitset>
#include <cmath>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define cl(a,b) memset(a,b,sizeof(a))
#define bp __builtin_popcount
#define pb push_back
#define mp make_pair
#define fin freopen("D://in.txt","r",stdin)
#define fout freopen("D://out.txt","w",stdout)
#define lson t<<1,l,mid
#define rson t<<1|1,mid+1,r
#define seglen (node[t].r-node[t].l+1)
#define pi 3.1415926
#define exp 2.718281828459
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <typename T>
inline void read(T &x){
T ans=0;
char last=' ',ch=getchar();
while(ch<'0' || ch>'9')last=ch,ch=getchar();
while(ch>='0' && ch<='9')ans=ans*10+ch-'0',ch=getchar();
if(last=='-')ans=-ans;
x = ans;
}
inline bool DBread(double &num)
{
char in;double Dec=0.1;
bool IsN=false,IsD=false;
in=getchar();
if(in==EOF) return false;
while(in!='-'&&in!='.'&&(in<'0'||in>'9'))
in=getchar();
if(in=='-'){IsN=true;num=0;}
else if(in=='.'){IsD=true;num=0;}
else num=in-'0';
if(!IsD){
while(in=getchar(),in>='0'&&in<='9'){
num*=10;num+=in-'0';}
}
if(in!='.'){
if(IsN) num=-num;
return true;
}else{
while(in=getchar(),in>='0'&&in<='9'){
num+=Dec*(in-'0');Dec*=0.1;
}
}
if(IsN) num=-num;
return true;
}
template <typename T>
inline void write(T a) {
if(a < 0) { putchar('-'); a = -a; }
if(a >= 10) write(a / 10);
putchar(a % 10 + '0');
}
/******************head***********************/
int n,m,ans;
char str[10][10];
int vis[10];
void dfs(int x,int cnt)
{
if(m == cnt){
ans++;
return ;
}
for( int i = x; i <= n; i++ ){ //枚举行
for( int j = 1; j <= n; j++ ){
//判断该列是否可放
if(vis[j] || str[i][j] == '.')continue;
vis[j] = 1;
dfs(i+1,cnt+1);
vis[j] = 0;
}
}
}
int main()
{
while(~scanf("%d%d",&n,&m) && n!=-1 && m!=-1){
ans = 0;
for( int i = 1; i <= n; i++ ){
scanf("%s",str[i]+1);
}
dfs(1,0);
printf("%d\n",ans);
}
return 0;
}