Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
107788 | 邹文浠白云六中 | 跳棋的挑战 | C++ | 解答错误 | 0 | 1000 MS | 260 KB | 683 | 2023-10-28 09:56:46 |
#include <bits/stdc++.h> using namespace std; int n; int sum,a[105]; bool b[105],c[105],d[105]; void print() { sum++; if(sum <= 3) { for(int k = 1;k <= n;k++) { cout << a[k]; if(k != n) cout << ' '; } cout << '\n'; } } void dfs(int i) { if(i > n) { print(); return ; } else { for(int j = 1;j <= n;j++) { if((b[j] == 0) && (c[i + j] == 0) && (d[i - j + n] == 0)) { b[j] = 0; c[i + j]; d[i - j + n] = 1; a[i] = j; dfs(i + 1); b[j] = 0; c[i + j] = 0; d[i - j + n] = 0; } } } } int main() { ios::sync_with_stdio(0); cin >> n; dfs(1); cout << sum; }