Sweep an n×m grid cell by cell. Carry an m-bit frontier mask. At each free cell: place vertical (set the bit below), place horizontal (consume the right cell), or skip a filled cell. Cost O(n·m·2m).
junior.md and professional.md for the proof that each decision appends one piece and the bijection between tilings and decision paths.