当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5157:Harry and magic string

题目描述
Harry got a string T, he wanted to know the number of T’s disjoint palindrome substring pairs. A string is considered to be palindrome if and only if it reads the same backward or forward. For two substrings of $T: \, x = T[a_1 \ldots b_1], \, y = T[a_2 \ldots b_2]$(where a1 is the beginning index of $x, b_1$ is the ending index of x. $a_2, b_2$ as the same of y), if both x and y are palindromes and $b_1 < a_2 \text{ or } b_2 < a_1$ then we consider (x, y) to be a disjoint palindrome substring pair of T.
输入解释
There are several cases.
For each test case, there is a string T in the first line, which is composed by lowercase characters. The length of T is in the range of [1,100000].
输出解释
For each test case, output one number in a line, indecates the answer.
输入样例
aca
aaaa
输出样例
3
15
提示
For the first test case there are 4 palindrome substrings of T.
They are:
S1=T[0,0]
S2=T[0,2]
S3=T[1,1]
S4=T[2,2]
And there are 3 disjoint palindrome substring pairs.
They are:
(S1,S3) (S1,S4) (S3,S4).
So the answer is 3.
来自杭电HDUOJ的附加信息
Recommend heyang

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 BestCoder Round #25

源链接: HDU-5157

最后修改于 2020-10-25T23:20:16+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)