Dynamic Programming21 sections · 916 units
Open in Course

Bitmask Encoding - Walkthrough

How to represent states

For a grid with nn columns, the profile has nn bits. Bit ii = 11 means column ii is filled at the current boundary. Example: n=4n = 4, mask = 10102=101010_2 = 10.

Columns 11 and 33 are filled, columns 00 and 22 are empty. Transition: placing a domino in column 00-11 (horizontal) changes mask from 10101010 to 10111011 (column 00 now filled). Or placing a vertical domino in column 00: changes mask from 10101010 to 10111011 and expects column 00 to be filled in next row.