2017 PSUT Coding Marathon |
---|
Finished |
Mr. Light now have a string that consists only of the three characters: ':', '(', and ')'.
Mr. Light considers a colon ‘:’ followed by a closing bracket ')' as a smiley face. So ":)" is a smiley face while "(:" is not. Now he wants to choose exactly one prefix (one or more characters at the beginning) of this string and mirror it (reverse it and flip the brackets).
For example, the string ":):((" mirrored is ")):(:".
What is the maximum number of smiley faces Mr. Light can get in the string after mirroring exactly one prefix?
The input contains a non-empty string of no more than 2 × 105 characters. Each character is either ':', '(', or ')'.
Print the maximum number of smiley faces Mr. Light can get after mirroring exactly one prefix.
:(:):(:):)
4
:)::(:(:
2
Name |
---|