In a given shape of the chessboard (the shape may be irregular) on the top of the pieces, chess pieces no difference. If you need to place any of the two pieces in the same row or column in the chessboard, please program the chessboard with a given shape and size, and put all the feasible arrangement C for the K pieces.
-------------------------------------------------------------------
#include<stdio.h>#include<string.h>#include<algorithm>#include<queue>#include<stack>int MN;Char Str[105][105];int dir[8][2]={{1,1},{-1,1},{-1,-1},{1,-1}};int k;int a=0;UsingNamespace Std;int book[15000];int m;voidDfs(int cur){If(k==m){A++;Return;}If(cur>=n)BoundaryReturn;For(Int J=0; J<n; J++)If(Book[j]==0&& Str[cur][j]==‘#‘)Judging conditions{Book[j]=1;Mark M++;Dfs(cur+1); Book[j]=0;Change back to make it easier for the next line of judgment m--;}Dfs(cur+1);To the next line}IntMain(){int I;While(scanf("%d%d", &n, &k), N!=-1&&k!=-1){A=0; M=0;For(I=0; I<n; I++)scanf ( "%s" ,str[i< Span class= "Sh-symbol"); memset (Book, 0,sizeof (Book )); dfs (0printf ( "%d\n< Span class= "sh-string" > ",a); return 0;< Span class= "Sh-cbracket" >
Searching for-----checkerboard issues