Skip to content

Conversation

@shatanshu3006
Copy link

This is another solution for the CSES "ChessBoard and Queens" Problem.

@shatanshu3006
Copy link
Author

Using Backtracking

Since the bounds are small, we can recursively backtrack over all ways to place
the queens, storing the current state of the board.

Then, we can try to place a queen at all squares $x, y$ if it isn't attacked by
a queen or blocked and recurse, before removing this queen and backtracking.

Finally, when we have placed all the queens and the board's state is valid, then
increment the answer.

Copy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant