题意:3 * N的格子 有一些点是坏的 用1X1和1X2的砖铺有多少种方法
题解:重新学了下轮廓线 写的很舒服
#include <bits/stdc++.h> using namespace std; typedef long long ll;int n, m; int vis[30][5]; ll dp[25][1 << 3];void dfs(int num, int i, int state, int nex) {if(num == 3){dp[i + 1][nex] += dp[i][state];return;}if(vis[i][num + 1] || (state & (1 << num))) dfs(num + 1, i, state, nex);else{dfs(num + 1, i, state, nex); //填1x1if(!vis[i + 1][num + 1] && !(nex & (1 << num)))dfs(num + 1, i, state, nex | (1 << num)); //竖着填1X2if(num + 2 <= 3 && !vis[i][num + 2] && !(state & (1 << (num + 1))))dfs(num + 2, i, state, nex); // 横着填1X2 } }int main() {scanf("%d%d", &n, &m);for(int i = 1; i <= m; i++){double x, y;scanf("%lf%lf", &x, &y);vis[(int)x + 1][(int)y + 1] = 1;}dp[1][0] = 1LL;for(int i = 1; i <= n; i++)for(int st = 0; st < 8; st++)if(dp[i][st] > 0){bool f = true;for(int k = 0; k < 3; k++){if(st & (1 << k) && vis[i][k + 1]){f = false;break;}}if(!f) continue;dfs(0, i, st, 0);}printf("%lld\n", dp[n + 1][0]);return 0; }