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 1574. Mathematicians and brackets

Some tests
Posted by MOPDOBOPOT (USU) 27 Jul 2012 14:16
Finally, I found the way to solve it in O(n) (needs about 4 full string-checks). In journey to this solution i tried to imagine that i'm cutting brackets like '()'. And watching what I can get by cutting all this pieces. Looking on new sequence I understood what I need to shift to get right bracket-sequence.

Here are some tests that helped me:

)))(()((
ans: 1

(()(()))
ans: 1

())(
ans: 1

))(())())((()(
ans: 1

Edited by author 27.07.2012 14:19