思路:因为每一列每一行只能有一个皇后,那么我们可以把这个问题转化到三个数组上,分别表示其列,对角线,反对角线;当三个位置皆没用过时,即可把皇后放在其列上。
代码如下
#include<iostream>
using namespace std;
const int N = 10086;
int n;
char str[N][N];
bool s[N], bg[N], ubg[N];
void dfs(int u
思路:因为每一列每一行只能有一个皇后,那么我们可以把这个问题转化到三个数组上,分别表示其列,对角线,反对角线;当三个位置皆没用过时,即可把皇后放在其列上。
代码如下
#include<iostream>
using namespace std;
const int N = 10086;
int n;
char str[N][N];
bool s[N], bg[N], ubg[N];
void dfs(int u