/ OPS / 题库 /

Regular Brackets

Regular Brackets

#描述#
A regular brackets sequence is defined below:<BR>
1. An EMPTY sequence is a regular brackets sequence;<BR>
2. If R is a regular brackets sequence, then R are both regular brackets sequences;<BR>
3. If R is a regular brackets sequence, then []R ()R R[] R() are regular brackets sequences.<BR>
4. If R1 and R2 are a regular brackets sequences, then R1R2 is a regular brackets sequence. <BR>
<BR>

Given a string consisting of brackets of two types find its longest substring that is a regular brackets sequence.

#格式#
##输入格式##
There are multiple cases in the input file. Process to the end of file.

Each case contains a string containing only characters ‘(’ , ‘)’ , ‘[’ and ‘]’ . The length of the string does not exceed 100.

There is an empty line after each case.

##输出格式##
Output the longest substring of the given string that is a regular brackets sequence in one line. If there are more than one answer, just output the first one. If there is no such substring, just output an empty line. Output an empty line after each test case.

#样例1#
##样例输入1##

([(][()]]()

([)]


##样例输出1##

[()]




#限制#
2000ms
32768KB

#提示#

#来源#
ycc

信息

ID
1739
难度
5
分类
category1 点击显示
标签
递交数
0
已通过
0
通过率
?
上传者