Dynamic Programming21 sections · 916 units
Open in Course

Counting Tilings - State Definition

What DP tracks

Let dp[c][mask]dp[c][mask] = number of ways to tile columns 00 to c1c-1 completely, with column cc having profile maskmask. The profile tells you which cells in column cc are already filled by vertical tiles from column c1c-1. Base case: dp[0][0]=1dp[0][0] = 1.

You start with no columns filled and an empty profile. All other dp[0][mask]dp[0][mask] are 00 because you can't have a non-empty profile before placing any tiles. Goal: dp[m][0]dp[m][0]. After filling all mm columns, the final profile must be empty (no tiles sticking out). This counts all complete tilings.