2022.1.27
题目网址:
https://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.
输入:
The first line of the input file contains a non-empty string, consisting of ?(? and ?)? characters. Its length does not exceed 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".
样例输入:
)((())))(()())
样例输出:
6 2
翻译:
描述:
这是处理规则括号序列的另一个问题。
我们应该提醒你括号序列是规则的,如果把 + 和 1 放到括号里面,我们应该可以得到一个正确的数学表达式。例如,序列(())(),(),(()(()))都是规则的,而)(,(()和(()))(都不是规则的。
你被给一个由(和)组成的字符串。你要去找到是规则括号序列的最长的子串。你还要去统计这样的子串的数量。
输入:
输入的第一行包括一个非空字符串,由字符(和)组成。字符串的长度不超过106。
输出:
打印出是规则括号序列的最长字符串的长度,以及这样的字符串的数量。如果没有找到这样的字符串,就写下唯一的一行,这一行打印出“0 1”。