#P12182. DerrickLo's Brackets (UBC002E)
DerrickLo's Brackets (UBC002E)
Description
DerrickLo has an integer array with numbers, and a array with characters which are either ( or ) (, ). Now he will generate bracket strings by selecting an interval () and perform the following operation to a string which is initially empty.
- For each integer from to , append copies of to .
After each generation, DerrickLo wants to know the longest good substring of . Please help him!
A good string is defined as,
-
An empty string is a good string.
-
If is a good string, then so does .
-
If are both good strings, then so does .
-
Any other strings are not good strings.
Input Format
The first line contains two integers .
The second line contains integers representing .
The third line contains a string representing .
For the next lines, each one contains two integers representing for a generation.
Output Format
Output lines. The -th one representing the -th answer.
3 2
2 3 1
()(
1 3
2 3
4
0
Hint
of the first generation is (()))(. Its longest good substring is (()), so output .
of the second generation is )))(. Its longest good substring is an empty string, so output .
京公网安备 11011102002149号