51| 八皇后 代码实现#include bits/stdc.h using namespace std; int n; const int N 15; bool st[N], st1[2*N], st2[2*N]; vector int path; int ret; void dfs(int x) { if (x n) { ret; if(ret 3) { for (auto x : path) cout x ; cout endl; } return ; } for (int y 1; y n; y) { if (st[y] || st1[y-xn] || st2[yx] ) continue; st[y] st1[y-xn] st2[yx] true; path.push_back(y); dfs(x1); st[y] st1[y-xn] st2[yx] false; path.pop_back(); } } int main () { cin n; dfs(1); cout ret endl; return 0; }