Time Limit: 1000MS
Memory Limit: 65536K
while the following character sequences are not:
(), , (()), (), ()[()]
Given a brackets sequence of characters a1a2 … an, your goal is to find the length of the longest regular brackets sequence that is a subsequence of s. That is, you wish to find the largest m such that for indices i1, i2, …, im where 1 ≤ i1 < i2 < … < im ≤ n, ai1ai2 … aim is a regular brackets sequence.Given the initial sequence
(, ], )(, ([)], ([(]
([(])], the longest regular brackets subsequence is
]; each input test will have length between 1 and 100, inclusive. The end-of-file is marked by a line containing the word “end” and should not be processed.