Editorial : THU Packing Puzzle
This editorial describes the row-counting formula implemented in model_sol.cpp. The problem is purely about packing three fixed polyomino shapes into a $n \times 3$ strip; the code encodes a case split that matches an optimal height.
Let $c_T, c_H, c_U$ be the counts. The solution accumulates a lower bound on the number of rows:
-
Pair $T$ with $U$: match $\min(c_T, c_U)$ pairs; each pair is charged $4$ rows (
min(t, u) * 4), then decrement those counts. -
Pair remaining $T$ with $H$: while both exist, pack in blocks that cost $7$ rows per unit of matching captured by
min(h, t/2)(two $T$’s with one $H$ in the intended pattern). If $T$ is odd and an $H$ remains, pay $5$ rows once. -
Leftover $T$ only: if $T$’s still remain, each full $T$ needs about two rows, with a final +1 row for parity (
2 * t + 1). -
Remaining $H$ and $U$: each leftover piece costs $3$ rows (
3 * (u + h)).
The program follows the above order: update t, h, u as it applies each macro step, then prints the accumulated row sum.
The constants $4$, $7$, $5$, $2$, and $3$ come from concrete optimal packings of the THU pieces in a height-$3$ strip; the implementation matches those patterns rather than recomputing a search.