Dynamic Programming21 sections · 916 units
Open in Course

State Transitions - Walkthrough

How masks change

Process column by column within a row, then row by row. At each cell, decide: place tile here or not. If cell (r,c)(r, c) is already filled (bit cc = 11 in mask), flip bit to 00 (it's handled) and move to next column.

If empty: place horizontal domino (fill cc and c+1c+1), place vertical domino (fill cc in next row's mask), or leave empty (invalid in full tiling). Valid transitions form a graph over masks. DP computes: for each row and mask, how many ways to reach this configuration.