#P4656. [CEOI 2017] Palindromic Partitions
[CEOI 2017] Palindromic Partitions
Description
You are given a string containing only lowercase letters. You need to partition it into as many blocks as possible, such that these blocks form a palindrome string.
For example, for the string abcab, partitioning it into ab c ab or just abcab is a valid way to make the blocks form a palindrome, while abc ab is not.
Input Format
The first line contains an integer , indicating the number of test cases.
The next lines each contain a string, representing the string you need to process. It is guaranteed that the string contains only lowercase letters.
Output Format
Output lines. For each input string, output one line containing an integer , indicating the maximum number of blocks the string can be partitioned into, such that these blocks form a palindrome.
4
bonobo
deleted
racecar
racecars
3
5
7
1
Hint
For of the testdata, . Let be the length of a single string, then .
Translated by ChatGPT 5
京公网安备 11011102002149号