1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| #include <bits/stdc++.h> using namespace std;
using ll = long long;
void dfs(int pos, int W, vector<ll>& cracks, ll mask) { if (pos == W) { cracks.push_back(mask); return; } if (pos > W) return;
if (pos + 2 <= W) { ll m = mask; if (pos + 2 != W) m |= (1LL << (pos + 2)); dfs(pos + 2, W, cracks, m); }
if (pos + 3 <= W) { ll m = mask; if (pos + 3 != W) m |= (1LL << (pos + 3)); dfs(pos + 3, W, cracks, m); } }
int main() { int W = 32; int H = 10;
vector<ll> cracks; dfs(0, W, cracks, 0);
int M = cracks.size();
vector<vector<int>> ok(M); for (int i = 0; i < M; i++) { for (int j = 0; j < M; j++) { if ((cracks[i] & cracks[j]) == 0) { ok[i].push_back(j); } } }
vector<ll> dp(M, 1), ndp(M);
for (int layer = 2; layer <= H; layer++) { fill(ndp.begin(), ndp.end(), 0); for (int i = 0; i < M; i++) { if (dp[i] == 0) continue; for (int j : ok[i]) { ndp[j] += dp[i]; } } dp = ndp; }
ll ans = 0; for (ll x : dp) ans += x;
cout << ans << "\n"; return 0; }
|