Doubt in editorial for CodeForces round #336 problem Zuma

Правка en1, от 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.

Теги #dp, doubt, editorial

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский ps06756 2015-12-24 10:38:39 637 Initial revision (published)