skittles_99's blog

By skittles_99, history, 8 years ago, In English

Hi Guys,I will always stuck at this type of problems.Here are some problems that involves domino tiling.
Problem1
Problem2
I found some tutorials on stackoverflow and on google search but I am unable to get it.
Is there any method to solve recurrence for this type of problem or some resources to learn will be helpful :)

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it +2 Vote: I do not like it

This is a classic problem of dynamic programming with bit masks.

The first problem you are trying to fill a 4xN board, this can be done iterating over columns, notice that if you are going to fill column K, you need to know the state of column K-1, K-1 may be full or may have some holes, for each hole you need to place an horizontal domino in column K, the trick is to have a bitmask representation for the state of column K-1 and iterate over all possible valid bitmasks for column K.

In the second problem N*M <= 100, this means than min(N, M) <= 10, this allows you to use the same approach as before.