Getting wrong answer in dp problem Pictures with Kittens (easy version). TC 45

Revision en5, by spirited_away_, 2019-07-13 22:52:58

Hello! I am solving Pictures with Kittens (easy version).

My approach is pretty much like knapsack. Suppose we are at index i, we have 2 options either to not pick or to pick. If our last pick and current index different == k then we will have to pick it.

my dp state is dp[curr][taken][last] which is what is our answer if we are at index = curr, and have took taken elements and our previous taken = last.

But this approach is giving WA on test case 45. Can anyone please tell me what i am missing?

Here is my solution: LINK

Thanks.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en8 English spirited_away_ 2019-07-13 23:00:49 64
en7 English spirited_away_ 2019-07-13 23:00:08 158
en6 English spirited_away_ 2019-07-13 22:54:54 39
en5 English spirited_away_ 2019-07-13 22:52:58 6 Tiny change: 'sion/56993119)\n\nThank' -> 'sion/56993440)\n\nThank'
en4 English spirited_away_ 2019-07-13 22:45:25 2 Tiny change: 'ick it. \nmy dp st' -> 'ick it. \n\nmy dp st'
en3 English spirited_away_ 2019-07-13 22:45:06 154
en2 English spirited_away_ 2019-07-13 22:39:07 6 Tiny change: 'sion/56993020)\n\nThank' -> 'sion/56993119)\n\nThank'
en1 English spirited_away_ 2019-07-13 22:37:59 585 Initial revision (published)