QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 2048 MB Total points: 100

#828. 回文解析

Statistics

Mark 正在研究字符串解析算法。目前,他对比回文串很感兴趣。回文串是指正读和反读都相同的字符串。例如,“racecar”就是一个回文串。Mark 想知道一个字符串可以被拆分成多少个回文串。例如,字符串“HELLO”可以被拆分为回文串“H”、“E”、“LL”和“O”。你的任务是:给定一个字符串,求出将其拆分为回文串的最小数量。

输入格式

输入的第一行包含一个整数 $n$($1 \le n \le 1000$),随后有 $n$ 行。每一行包含一个仅由大小写字母和数字组成的字符串,且不含空格。所有字符串的总长度不超过 $5000$。

输出格式

输出 $n$ 行,每一行包含对应的输入字符串可以被拆分成的回文子串的最小数量。

样例

输入 1

3
HELLO
abcdefg
racecar11

输出 1

4
7
2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.