#codefestival2017qualcd. [code_festival_2017_qualc_d]Yet Another Palindrome Partitioning
[code_festival_2017_qualc_d]Yet Another Palindrome Partitioning
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.
Sample Input 1
aabxyyzz
Sample Output 1
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
.
Sample Input 2
byebye
Sample Output 2
1
byebye
can be permuted to form a palindrome byeeyb
.
Sample Input 3
abcdefghijklmnopqrstuvwxyz
Sample Output 3
26
Sample Input 4
abcabcxabcx
Sample Output 4
3
The solution is to partition as abcabcxabcx
= a
+ b
+ cabcxabcx
.