sudipta550's blog

By sudipta550, history, 4 years ago, In English

I need help in the tiling problem.This the problem I cannot understand how to count the total no of dominos in the case of blue colors. Should I write two dp tables one is the row-major matrix(for red) and the other is the column-major matrix(for blue)? I cannot understand how to write. Please help...

  • Vote: I like it
  • +7
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

112847614 You can look at this submission, it is quite neat.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks for your response. ****This is going above my head. Can you please give me some intuition behind this solution?

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      dp[i] is the contribution to the answer if we have i consecutive white cells in a row/column.

      Let's take the case of row. If last cell if blue then it's equivalent to dp[i-1]. If last cell is red but 2nd last cell is blue it is equivalent to dp[i-2]. And the remaining case, if both last 2 cells are red, it is equivalent to dp[i-2] and a tile on last 2 positions. That tile will contribute for all the 1<<(i-2) states of the previous cells.

      Hence, dp[i]=dp[i-1]+2*dp[i-2]+a[i-2] where a[x]=2^x.

      That was the main intuition behind the solution.