xdnjf @ 2023-06-02 22:00:36
#include<cstdio>
#include<iostream>
using namespace std;
long long ans,zl[15][15],n;
void bfs(long long x) {
if(x>n) {
ans++;
if(ans<=3) {
for(long long i=1; i<=n; i++) {
cout<<zl[1][i]<<' ';
}
puts("");
}
return;
} else {
for(long long i=1; i<=n; i++) {
if(zl[2][i]!=1&&zl[3][x+i]!=1&&zl[4][n+x-i]!=1) {
zl[1][x]=i;
zl[2][i]=1;
zl[3][x+i]=1;
zl[4][n+x-i]=1;
bfs(x+1);
zl[2][i]=0;
zl[3][x+i]=0;
zl[4][n+x-i]=0;
}
}
}
}
signed main() {
scanf("%lld",&n);
bfs(1);
printf("%lld\n",ans);
return 0;
}
by xdnjf @ 2023-06-02 22:20:28
61pts