ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1183. Brackets Sequence

DP solution
Posted by MSDN 9 Mar 2008 18:26
S - it is a line
Create a matrix
F[i][j] is a decision with i on j a symbol
If S[i] it is a closing bracket, F[i][j] =1 + F[i+1][j]
If S[i] a closing bracket that is two cases:
1) We add a closing bracket - 1 + min(F[i+1][k] + F[k+1][j]), where i<k<=j
2) Is in line closing - min(F[i+1][k-1], F[k+1][j]), where S[k] = S[i] and i<k<=j
Re: DP solution
Posted by Crash_access_violation 10 Mar 2008 22:49
Interesting... But what you output? Please explain to me
Re: DP solution
Posted by hoan 26 Nov 2010 00:00
> 1) We add a closing bracket - 1 + min(F[i+1][k] + F[k+1][j]), where i<k<=j

if we want to add a bracket we can add it in (i+1)position.
and dont necessary too check all the kind.

sorry for my poor english.
GOOD LUCK!!!