Dynamic Programming21 sections · 916 units
Open in Course

Chessboard Coloring - Problem Statement

Non-tiling variant

Color an n×mn \times m grid with 22 colors such that no 2×22 \times 2 region is monochromatic. Profile: the coloring of the last row (22^mm states).

Transition: next row's coloring must differ appropriately. Constraint: for each 2×22 \times 2 block involving last row and current row, check it's not monochromatic. DP: dp[row][mask]dp[row][mask] = ways to color rows 0..row0..row with last row having coloring maskmask. Enumerate valid next colorings.