原题链接--
https://acs.jxnu.edu.cn/problem/CF5Chttps://acs.jxnu.edu.cn/problem/CF5C
Longest Regular Bracket Sequence
2000ms 262144K
描述:
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.
译文:第一行输入文件包含一个非空字符串,由«(»和«)»组成。它的长度不超过106。
输出:
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