标签:stream class break col alt ring clu har ret
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; int n,k; char ch[10][10]; long long ans; int vis[10]; int kk; void dfs(int x){ if(kk == k){ ans++; return; } if(x >= n) return; for(int y = 0; y < n; y++){ if(!vis[y] && ch[x][y] == ‘#‘){ vis[y] = 1; kk++; dfs(x + 1); vis[y] = 0; kk--; } } dfs(x + 1); } int main(){ // freopen("in","r",stdin); ios::sync_with_stdio(0); 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 >> ch[i][j]; } } memset(vis,0, sizeof(vis)); ans = 0; kk = 0; dfs(0); cout << ans << endl; } return 0; }
标签:stream class break col alt ring clu har ret
原文地址:https://www.cnblogs.com/xcfxcf/p/12683844.html