最长的常规支架序列|断续器 (jxnu.edu.cn)https://acs.jxnu.edu.cn/problem/CF5C
描述:
This is yet another problem dealing with regular bracket sequences.
We should remind you that a bracket sequence is called regular, if by inserting «+» and «1» into it we can get a correct mathematical expression. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.
You are given a string of «(» and «)» characters. You are to find its longest substring that is a regular bracket sequence. You are to find the number of such substrings as well.
这是处理常规括号序列的问题。
我们将提醒你这个序列叫做正则序列,如果在其中插入《+》和《1》我们将得到正确的数学表达式。例如,序列 «(())()», «()»和 «(()(()))»是正则, 然而 «)(», «(()» 和 «(()))(» 不是。
你将获得一串《(》和《)》字符。你将找到其最长子字符串,该子字符串是常规序列。你还需要找到其类似子字符串。
输入:
The first line of the input file contains a non-empty string, consisting of «(» and «)» characters. Its length does not exceed 106.
第一行输入一行非空字符串,包含《(》和《)》字符。他的长度不超过10^6。
输出:
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
输出正则括号序列的最长长度,以及这种序列的个数,如果没有,则输出“0 1”。
样例输入:
)((())))(()())
样例输出:
6 2
样例输入:
))(
样例输出:
0 1