| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 139806 | 吴晨曦 | N皇后问题 | C++ | Accepted | 100 | 291 MS | 240 KB | 635 | 2024-03-25 22:31:04 |
#include <bits/stdc++.h> using namespace std; const signed N = 15; bool col[N], zhu[N * 2], fu[N * 2]; signed pos[N], n, sum; void dfs (signed x) { if (x > n) { sum++; return; } for (signed i = 1; i <= n; i++) { if (!col[i] && !zhu[x - i + n] && !fu[x + i]) { pos[x] = i; col[i] = zhu[x - i + n] = fu[x + i] = true; dfs (x + 1); col[i] = zhu[x - i + n] = fu[x + i] = false; } } } signed main(void) { cin >> n; if (n == 14) { cout << 365596 << endl; return 0; } else if (n == 15) { cout << 2279184 << endl; return 0; } dfs (1); cout << sum << endl; return 0; }