Yet Another Palindrome Partitioning

AtCoder
IDcode_festival_2017_qualc_d
Time3000ms
Memory256MB
Difficulty
We have a string $s$ consisting of lowercase English letters. Snuke is partitioning $s$ into some number of non-empty substrings. Let the subtrings obtained be $s_1$, $s_2$, $...$, $s_N$ from left to right. (Here, $s = s_1 + s_2 + ... + s_N$ holds.) Snuke wants to satisfy the following condition: * For each $i$ ($1 \leq i \leq N$), it is possible to permute the characters in $s_i$ and obtain a palindrome. Find the minimum possible value of $N$ when the partition satisfies the condition. ## Constraints * $1 \leq |s| \leq 2 \times 10^5$ * $s$ consists of lowercase English letters. ## Input Input is given from Standard Input in the following format: $s$ [samples]
Samples
Input #1
aabxyyzz
Output #1
2

The solution is to partition $s$ as `aabxyyzz` = `aab` + `xyyzz`. Here, `aab` can be permuted to form a palindrome `aba`, and `xyyzz` can be permuted to form a palindrome `zyxyz`.
Input #2
byebye
Output #2
1

`byebye` can be permuted to form a palindrome `byeeyb`.
Input #3
abcdefghijklmnopqrstuvwxyz
Output #3
26
Input #4
abcabcxabcx
Output #4
3

The solution is to partition $s$ as `abcabcxabcx` = `a` + `b` + `cabcxabcx`.
API Response (JSON)
{
  "problem": {
    "name": "Yet Another Palindrome Partitioning",
    "description": {
      "content": "We have a string $s$ consisting of lowercase English letters. Snuke is partitioning $s$ into some number of non-empty substrings. Let the subtrings obtained be $s_1$, $s_2$, $...$, $s_N$ from left to ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "code_festival_2017_qualc_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "We have a string $s$ consisting of lowercase English letters. Snuke is partitioning $s$ into some number of non-empty substrings. Let the subtrings obtained be $s_1$, $s_2$, $...$, $s_N$ from left to ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments