Search-----Checkerboard Issues

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.