惊恐!!!!!
今天才发先我还没有写八皇后...
然后就水了一发。
立flag不1A就退役...
果然没有辜负我.
原来以我的水平切八皇后还没有问题2333
突然有些害怕
#include <cstdio> #include <cstring> #include <iostream> using namespace std; inline int read() { int res = 0;char ch=getchar(); while(!isdigit(ch))ch=getchar(); while(isdigit(ch))res=(res<<3)+(res<<1)+(ch^48), ch=getchar(); return res; } #define reg register int n; bool vis1[15], vis2[15*2], vis3[15*2]; int ans; int tim; int road[15]; inline void print() { for (reg int i = 1 ; i <= n ; i ++) printf("%d ", road[i]); puts(""); } void dfs(int x) { if (x > n) { if (++tim <= 3) print(); ans++; return ; } for (reg int i = 1 ; i <= n ; i ++) { if (vis1[i]) continue; if (vis2[x+i]) continue; if (vis3[x+n-i]) continue; vis1[i] = 1, vis2[x+i] = 1, vis3[x+n-i] = 1; road[x] = i; dfs(x + 1); vis1[i] = 0, vis2[x+i] = 0, vis3[x+n-i] = 0; road[x] = 0; } } int main() { n = read(); dfs(1); printf("%d ", ans); return 0; }