atcoder#CODEFESTIVAL2017QUALCD. Yet Another Palindrome Partitioning
Yet Another Palindrome Partitioning
Score : points
Problem Statement
We have a string consisting of lowercase English letters. Snuke is partitioning into some number of non-empty substrings. Let the subtrings obtained be , , , from left to right. (Here, holds.) Snuke wants to satisfy the following condition:
- For each (), it is possible to permute the characters in and obtain a palindrome.
Find the minimum possible value of when the partition satisfies the condition.
Constraints
- consists of lowercase English letters.
Input
Input is given from Standard Input in the following format:
Output
Print the minimum possible value of when the partition satisfies the condition.
aabxyyzz
2
The solution is to partition as aabxyyzz
= aab
+ xyyzz
.
Here, aab
can be permuted to form a palindrome aba
, and xyyzz
can be permuted to form a palindrome zyxyz
.
byebye
1
byebye
can be permuted to form a palindrome byeeyb
.
abcdefghijklmnopqrstuvwxyz
26
abcabcxabcx
3
The solution is to partition as abcabcxabcx
= a
+ b
+ cabcxabcx
.