类似于n皇后的思想,只要把dfs表示放置情况的数字压缩成一个整数,就能实现记忆化搜索了。 一些有关集合的操作: {i}在集合S内:S&(1<<i)==1; 将{i}加入集合S:S=S|(1<<i); 集合S内包含了{0,1,2,...,n-2,n-1}:S==(1<<n)-1; 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 using namespace std; 5 6 typedef long long llt; 7 ...