#include<iostream>
#include<cstring>
using namespace std;
int n,k,bb[]={},sum=;
char aa[][];
void dfs(int a,int b)
{
if(b>=n)
{
if(a==k)
sum++;
return;
}
for(int i=;i<n;i++)
{
if(!bb[i]&&aa[b][i]=='#')
{
bb[i]=;
dfs(a+,b+);
bb[i]=;
} }
dfs(a,b+);
}
int main()
{
while(cin>>n>>k)
{ int q=;
sum=;
memset(bb,,sizeof(bb));
if(n==-||k==-)break;
for(int i=;i<n;i++)
for(int j=;j<n;j++) cin>>aa[i][j]; dfs(,);
cout<<sum<<endl;
} return ;
}
相关文章
- poj1321 棋盘(dfs)
- Preparing Olympiad---cf550B(DFS或者状态压缩模板)
- HDU 1045(炮台安置 DFS)
- HDU 1560 DNA sequence DFS
- 图的基本操作(基于邻接表):图的构造,深搜(DFS),广搜(BFS)
- NOI 193棋盘分割.cpp
- Codeforces Round #375 (Div. 2) D. Lakes in Berland dfs
- uva :10123 - No Tipping(dfs + 几何力矩 )
- codeforces 700B Connecting Universities 贪心dfs
- codeforces 681D Gifts by the List dfs+构造