int state[2005]; int stateCount[2005]; longlong dp[10][2005][105]; int stateCnt = 0; int N, K;
voiddfs(int s, int num, int cur){ if (cur >= N) { state[++stateCnt] = s; stateCount[stateCnt] = num; return; } dfs(s, num, cur + 1); dfs(s + (1 << cur), num + 1, cur + 2); }
inlineboolisCompatible(int i, int j){ if (state[i] & state[j]) returnfalse; if ((state[i] << 1) & state[j]) returnfalse; if (state[i] & (state[j] << 1)) returnfalse; returntrue; }
intmain(){ cin >> N >> K; dfs(0, 0, 0); for (int i = 1; i <= stateCnt; i++) dp[1][i][stateCount[i]] = 1; for (int i = 2; i <= N; i++) { for (int j = 1; j <= stateCnt; j++) { for (int k = 1; k <= stateCnt; k++) { if (!isCompatible(j, k)) continue; for (int l = stateCount[j]; l <= K; l++) { dp[i][j][l] += dp[i - 1][k][l - stateCount[j]]; } } } } longlong ans = 0; for (int i = 1; i <= stateCnt; i++) ans += dp[N][i][K]; cout << ans << endl; }
boolcheck(int s){ for (int i = 0; i < m; i++) if (s >> i & 1 && ((s >> (i + 1) & 1) || (s >> (i + 2) & 1))) returnfalse; returntrue; }
intmain(){ cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { char ch; cin >> ch; if (ch == 'H') g[i] |= 1 << j; } for (int i = 0; i < 1 << m; i++) { if (check(i)) { state.emplace_back(i); stateCnt.emplace_back(__builtin_popcount(i)); } }
for (int i = 0; i < n + 2; i++) for (int j = 0; j < state.size(); j++) for (int k = 0; k < state.size(); k++) for (int u = 0; u < state.size(); u++) { int a = state[j], b = state[k], c = state[u]; if (a & b || a & c || b & c) continue; if (g[i] & c) continue; f[i & 1][k][u] = max(f[i & 1][k][u], f[i - 1 & 1][j][k] + stateCnt[u]); } cout << f[n + 1 & 1][0][0] << endl; }
constint maxN = 12, maxS = 1 << maxN; constint mod = 1e8; int g[maxN]; int dp[maxN][maxS]; vector<int> state;
int M, N;
voiddfs(int s, int cur){ if (cur >= N) { state.emplace_back(s); return; } dfs(s, cur + 1); dfs(s | (1 << cur), cur + 2); }
intmain(){ cin >> M >> N; for (int i = 0; i < M; i++) for (int j = 0; j < N; j++) { int num; cin >> num; num = 1 - num; g[i] |= num << j; } dfs(0, 0); for (int i : state) if ((i & g[0]) == 0) dp[0][i] = 1; for (int i = 1; i < M; i++) { for (int j = 0; j < state.size(); j++) { for (int k = 0; k < state.size(); k++) { int u = state[j], v = state[k]; if (v & u || v & g[i]) continue; dp[i][v] = (dp[i][v] + dp[i - 1][u]) % mod; } } } int ans = 0; for (int i : state) ans = (ans + dp[M - 1][i]) % mod; cout << ans << endl; }