2265: Pieces

内存限制:128 MB 时间限制:3.000 S
评测方式:文本比较 命题人:
提交:24 解决:13

题目描述

You heart broke into pieces.My string broke into pieces.But you will recover one day,and my string will never go back.
Given a string s.We can erase a subsequence of it if this subsequence is palindrome in one step. We should take as few steps as possible to erase the whole sequence.How many steps do we need?
For example, we can erase abcba from axbyczbea and get xyze in one step.

输入

The first line contains integer T,denote the number of the test cases. Then T lines follows,each line contains the string s (1<= length of s <= 16).
T<=10.

输出

For each test cases,print the answer in a line.

样例输入 复制

2
aa
abb

样例输出 复制

1
2

来源/分类