Topic Portal
1 /*2 DFS: Because only one row or column is placed, you can enumerate from which line to start, Dfs put pieces, the same column can only have one3 */4#include <cstdio>5#include <algorithm>6#include <cstring>7 using namespacestd;8 9 Charmaze[Ten][Ten];Ten BOOLvis[Ten]; One intN, K, ans; A - voidDasointXintnum) { - for(intI=1; i<=n; ++i) { the if(Maze[x][i] = ='#'&&!Vis[i]) { - if(num = =1) ans++; - Else { -Vis[i] =true; + for(intj=x+1; j<=n-num+2; ++j) { -DFS (J, num-1); + } AVis[i] =false; at } - } - } - } - - intMainvoid) {//POJ 1321 Checkerboard Issues in while(SCANF ("%d%d", &n, &k) = =2) { - if(n = =-1&& k = =-1) Break; to for(intI=1; i<=n; ++i) scanf ("%s", Maze[i] +1); +memset (Vis,false,sizeof(VIS)); Ans =0; - for(intI=1; i<=n-k+1; ++i) { the DFS (i, k); * } $printf ("%d\n", ans);Panax Notoginseng } - the return 0; +}
DFS POJ 1321 Checkerboard Issues