02.08 Longest Regular Bracket Sequence

该问题要求找出给定括号字符串中最长的正则括号序列及其数量。正则括号序列可以通过插入加号和数字1形成有效数学表达式。输入为一串由'('和')'组成的字符串,输出是最长正则子串的长度及这样的子串个数。示例中,对于输入'((())))(())',最长正则子串为6个字符,共有2个这样的子串。
摘要由CSDN通过智能技术生成

最长的常规支架序列|断续器 (jxnu.edu.cn)icon-default.png?t=M0H8https://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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值