G - Count Grid 3-coloring Editorial
by
YuJiahe
Assume that \(W \le H\).
We can find that the number of valid states of a \(1 \times W\) grid is \(3 \times 2^{W - 1}\), the number of valid states of a \(2 \times W\) grid is \(2 \times 3^W\).
So we can design a DP with \(O(H2^W)\) states and \(O(H3^W)\) transformations.
Because \(\min(H, W) \le 14\), we are done.
posted:
last update: