Help Me Understand It: My brain can't think of anything else!

Правка en2, от Rapt0r_nj, 2025-01-11 12:49:12

Summary:

Help me understand this solution to the problem CSES Counting Tillings

Details:

While researching a good way to implement solution to the problem, I came across this incredibly concise solution, which solves the problem cell by cell and not the traditional column by column approach. I've been trying to understand the solution for two days now, but can't find a way. Not unexpectedly, I have no friends.

I know how the column by column approach works, I need help solving it cell by cell as in the linked solution.

Problem statement:

Find the ways to tile a n*m grid with 1*2 or 2*1 dominos.

Key Insights in the solution linked:

Although I don't understand it fully, apparently: DP[j][i][mask] is defined to be something like ways to tile full (i-1) columns, and ith column to jth row; with mask sticking out to (i+1)th column, but I'm not sure.

  1. Its iterating over columns.
  2. For each column, its iterating over each cell
  3. For each cell, its solving the DP for all masks, (in a weird way: I don't even understand how mask is defined for each cell)
Теги help me, need help

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский Rapt0r_nj 2025-01-11 12:49:12 18 Tiny change: 'nd a way. As usual, **I have' -> 'nd a way. Not unexpectedly, **I have'
en1 Английский Rapt0r_nj 2025-01-11 07:24:54 1328 Initial revision (published)