Poj 3254 Corn Fields, status compression DP
Question Link
Question:
There are many grids in a matrix. Each grid has two statuses: grazing and not grazing. grazing can be expressed as 1. Otherwise, 0 is used to show cattle in this farm, two adjacent squares must not be placed at the same time, that is, the ox and the ox cannot be adjacent. Ask how many cow solutions are available (not a single cow is also a solution)
State [I] indicates a solution that ensures non-adjacent rows.
Status: dp [I] [state [j] Number of solutions that meet the conditions in row I when the status is state [j]
State Transfer: dp [I] [state [j] = Sigma dp [I-1] [state '] (state' is all States that meet the condition)
Nclude
# Include
# Include
# Define deusing namespace std; const int mod = 100000000; int state [1 <13], cnt; // for a row, ensure that the non-adjacent scheme int dp [20] [1 <13]; int cur [20]; // The value of cur [I] in the binary form 0 indicates that it can be put, 1 indicates that it cannot be placed. Int main () {int n, m, I, j, k; scanf ("% d", & n, & m); int M = 1 <