#12276. [CEOI 2017] Palindromic Partitions

    ID: 12276 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>贪心2017CEOI(中欧)哈希 hashing

[CEOI 2017] Palindromic Partitions

Problem 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 TT, indicating the number of test cases.

The next TT 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 TT lines. For each input string, output one line containing an integer xx, 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 100%100\% of the testdata, 1≤T≤101 \le T \le 10. Let LL be the length of a single string, then 1≤L≤1061 \le L \le 10^6.

Translated by ChatGPT 5