P8650 [Lanqiao Cup 2017 NOI Qualifier A] Regular Expression 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 $6$.
Input Format
A regular expression made up of `x()|`. The input length does not exceed $100$, and it is guaranteed to be valid.
Output Format
Output the length of the longest string that this regular expression can accept.
Explanation/Hint
Lanqiao Cup 2022 Provincial Contest Group A, Problem G.
Translated by ChatGPT 5