Doubt in editorial for CodeForces round #336 problem Zuma

Revision en1, by ps06756, 2015-12-24 10:38:39

Hello all, I am trying to understand the algorithm mentioned in the editorial for the following problem
Zuma Here is its editorial editorial.

In the case, when the ith color matches with the kth color in the range [i...j], shouldn't we be doing

D[i][j] = D[i+1][k-1] + D[k+1][j] + 1, instead of
D[i][j] = D[i+1][k-1] + D[k+1][j]
?

This is because, we have to destroy the matching characters in ith position with kth position also, which will take 1 step extra.

Tags #dp, doubt, editorial

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English ps06756 2015-12-24 10:38:39 637 Initial revision (published)