#P8650. [蓝桥杯 2017 省 A] 正则问题
[蓝桥杯 2017 省 A] 正则问题
Problem Description
Consider a simple regular expression:
A regular expression consists only of x, (, ), and |.
Xiaoming wants to find the length of the longest string that this regular expression can accept.
For example, ((xx|xxx)x|(x|xx))xx can accept the longest string xxxxxx, whose length is .
Input Format
A regular expression made up of x()|. The input length does not exceed , and it is guaranteed to be valid.
Output Format
Output the length of the longest string that this regular expression can accept.
((xx|xxx)x|(x|xx))xx
6
Hint
Lanqiao Cup 2022 Provincial Contest Group A, Problem G.
Translated by ChatGPT 5