#P8650. [蓝桥杯 2017 省 A] 正则问题

    ID: 9857 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>2017递归蓝桥杯省赛

[蓝桥杯 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 66.

Input Format

A regular expression made up of x()|. The input length does not exceed 100100, 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