Dynamic Programming21 sections · 916 units
Open in Course

Counting Tilings - Problem Statement

CSES 2181

Given an n×mn \times m grid, count how many ways you can tile it completely using 1×21 \times 2 and 2×12 \times 1 dominoes. Both dimensions can be up to 1010, and the answer can be huge, so report it modulo 109+710^9 + 7.

For example, a 2×32 \times 3 grid has 33 tilings: all horizontal, all vertical, or mixed. You need to count these systematically without missing or double-counting any. This is the canonical broken profile problem. Before reading the solution, think: how would you track which cells are filled as you go column by column?