DreamingBoy's blog

By DreamingBoy, 8 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

»
8 years ago, # |
  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.

  • »
    »
    8 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Can you share the code??

    I can't write code.

    • »
      »
      »
      8 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I can, but I will not. I you really want to get the idea, you must implement it by yourself.