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

Правка en4, от spirited_away_, 2019-07-13 22:45:25

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.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en8 Английский spirited_away_ 2019-07-13 23:00:49 64
en7 Английский spirited_away_ 2019-07-13 23:00:08 158
en6 Английский spirited_away_ 2019-07-13 22:54:54 39
en5 Английский spirited_away_ 2019-07-13 22:52:58 6 Tiny change: 'sion/56993119)\n\nThank' -> 'sion/56993440)\n\nThank'
en4 Английский spirited_away_ 2019-07-13 22:45:25 2 Tiny change: 'ick it. \nmy dp st' -> 'ick it. \n\nmy dp st'
en3 Английский spirited_away_ 2019-07-13 22:45:06 154
en2 Английский spirited_away_ 2019-07-13 22:39:07 6 Tiny change: 'sion/56993020)\n\nThank' -> 'sion/56993119)\n\nThank'
en1 Английский spirited_away_ 2019-07-13 22:37:59 585 Initial revision (published)