提交时间:2024-03-09 09:00:57
运行 ID: 136378
#include <bits/stdc++.h> using namespace std; int n, lim , sum = 0; void test(int row, int left, int right) { int pos, p; if(row != lim) { pos = lim& ~ (row | left | right); while(pos != 0) { p = pos& -pos; pos = pos-p; test(row + p, (left + p) << 1, (right + p) >> 1); } } else { sum++; } } int main() { cin >> n; lim = (1 << n) - 1; test(0, 0, 0); cout << sum; return 0; }