Harry and magic string

Problem Description
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[a1…b1],y=Ta2…b2, if both x and y are palindromes and b1<a2 or b2<a1 then we consider (x, y) to be a disjoint palindrome substring pair of T.

Input
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].

Output
For each test case, output one number in a line, indecates the answer.

Sample Input
aca
aaaa

Sample Output
3
15
Hint
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.

http://blog.csdn.net/dacc123/article/details/51371453

问题描述
哈利有一个字符串T,他想知道T不相交的回文字符串双的数量。一个字符串被认为是回文当且仅当它读取相同的后退或前进。T的两子:x = T(a1…b1),y = Ta2…b2,如果x和y是回文和b1 < a2和b2 < a1然后我们认为(x,y)是一个不相交的回文字符串双T。
输入
有几种情况。
对于每个测试用例,T在第一行是一个字符串,它是由小写字母。T的长度范围内的[100000]。
输出
对于每个测试用例,输出一个数字在一条线,indecates答案。
样例输入
aca
aaaa级
样例输出
3
15
提示
第一个测试用例有4个回文T的子字符串。
它们是:
S1 = T(0,0)
S2 = T(0,2)
S3 = T[1]
S4 = T(2,2)
有3个不相交的回文字符串对。
它们是:
(S1、S3)(S1、S4)(S3、S4)。
所以答案是3。