IntuitOA #21
Set Total Palindrome Transformation Cost
HardJudge-ready
Topics (AI-labelled)Bits & MathPrefix & RangesHashing
A string that can be rearranged into a palindrome is called palindrome-like. For any substring, characters may be changed; find the minimum number of changes needed to make it palindrome-like, and output the sum of these costs over all substrings. Rearrangement is allowed here, as the statement defines.
See below for this site's input format and constraints.
Input
A single line containing a string s of lowercase English letters only, 1≤|s|≤100000.
Output
Output the total palindrome-like change cost over all substrings.
Example 1
Input:
abca
Output:
6
Example 2
Input:
aabb
Output:
1
Example 3
Input:
abc
Output:
3
Editorial
Loading solution…