time limit per test:1s
memory limit per test:256MB
raised a question:
Given a string of lengthcontaining only lowercase letters.
You need to select several non-empty substrings of so that they are disjoint pairwise, and each substring is a palindrome.
Assuming you have selected substrings that satisfy the above conditions, your score is the sum of the lengths of all substrings minus . It is
But is a dedicated person, and to increase difficulty, Little L requires that each palindrome string contain at most one kind of letter
wants you to find the maximum score.
A positive integer in the first line represents the number of test groups, for each group of test data:
The only line contains a string of length which containing only lowercase letters.
For each test data, print a number representing the maximum score.
2 etxabaxtezwkdwokdbbb aaaaa
2 4
时间限制: 1s
内存限制:256MB
提出了一个问题:
给定一个长度为 的字符串 ,其中只包含小写字母。
你需要选择 的几个非空子串,使它们成对不相交,并且每个子串都是一个回文。
假设您选择了满足上述条件的 个子串 ,那么您的得分就是所有子串的长度之和减去 ,即
但 是个有心人,为了增加难度, 要求每个回文字符串最多包含一种字母
希望你找出最高分。
第一行的正整数 代表测试组数
每组测试数据唯一一行包含长度为 的字符串,该字符串只包含小写字母。
为每个测试数据打印一个代表最高分的数字。
2 etxabaxtezwkdwokdbbb aaaaa
2 4
难度等级: | 0 |
总通过次数: | 20 |
总提交次数: | 88 |