Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Alternate Solution #119

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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