FortinetOA #5
Maximize Beautiful Substrings
Estimated HardJudge-ready
The string contains only lowercase letters and dots; each dot can be replaced with any lowercase letter. A beautiful substring is a contiguous substring whose characters are all the same. Find the maximum total number of beautiful substrings after the replacements.
The source problem's rules and examples are clear; this site adds the input character set, the length limit, and stdin/stdout.
Input
A single line containing the string color (1≤length≤2000), whose characters are only a-z or . (dot).
Output
Output the maximum number of beautiful substrings.
Example 1
Input:
.a.bb.
Output:
13
Example 2
Input:
a...b
Output:
11
Example 3
Input:
....
Output:
10
Editorial
Loading solution…