51bool CanIMove(
const std::array<std::array<int, n>, n>& board,
int row,
54 for (
int i = 0; i < col; i++) {
55 if (board[row][i] == 1) {
60 for (
int i = row, j = col; i >= 0 && j >= 0; i--, j--) {
61 if (board[i][j] == 1) {
66 for (
int i = row, j = col; i <= n - 1 && j >= 0; i++, j--) {
67 if (board[i][j] == 1) {
81void NQueenSol(std::array<std::array<int, n>, n> board,
int col) {
86 for (
int i = 0; i < n; i++) {
87 if (CanIMove(board, i, col)) {
89 NQueenSol(board, col + 1);