DreamingBoy's blog

By DreamingBoy, 9 years ago, In Russian

Hello Codeforces :) It's again me!

Please help me with this problem -> link

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
9 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

dp[l][r] = string with minimal size that contains s[l...r] as subsequence.

dp[l][r] = min{ dp[l][i] + dp[i + 1][r] | l <= i < r }
dp[l][r] = min(dp[l][r], s[l] + dp[l + 1][r — 1] + s[r]) if s[l] = '(' and s[r] = ')' (or '[', ']')

Plus means concatination, min means string with mininal length.