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

建议使用的浏览器:

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

6517:Bring Bring Big Teacher Brother

题目描述
"Why are you shouting so loudly? Why don't you go to the property control? You try roar again?!"

After the gentle and easy-going Master Sun uttered a lot of adrenaline-provoking words, people did not hate him at all, but liked him more. His paragraph became a source of happiness for people. For example, his idea about meeting and working is very famous: "When the meeting is so serious, everyone is being scolded, how can you laugh when everyone is accepting opinions.Should I smile?smile to the death photo of your horse ".


Later, the Master Sun became an indispensable part of people's life, and people consider what he said an abstract Bible.

definition:
If the substring $s[l .. r]$ of a string s is an abstract Bible, if and only if $l = r$ or satisfies the following conditions:

1. $mid$ is an integer, and the character s[mid] appears only once in $s[l .. r]$. (where mid is defined as $\frac{(l+r)}{2}$ )

2. $s[l .. mid-1] = s[mid + 1 .. r]$.

3. $s[l .. mid-1]$ is also an abstract Bible.

Now, given a string s, the happy value of this string is

$$\sum_{l=1}^{\left|s \right|} \sum_{r=l}^{\left|s \right|} G(s[l..r])\times (r-l+1)^2$$

Where $G(t)=1$ if and only if t is an abstract Bible, otherwise $G(t)=0$.


On this day, Mr. Sun is interacting with his neighbour's softly and gently. Every word he says has been all memorized by you. Let's call it string s. You want to quote classics to the people around you. But quoting classics is not equivalent to copying. So you want to know how much happy value can be brought by changing at most one character of the original string s.
输入解释
First line containing single integer T representing testcase number.
Next T lines each line containing a string.

$|s| \leq 10^5$, s only contain lowercase letter.
输出解释
T lines,each line one integer representing the answer.
输入样例
2
abacaba
zyz
输出样例
83
12
提示
substring
[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[1,3],[3,5],[5,7],[1,7] are abstract bible.
Answer = 1 * 7 + 9 + 9 + 9 + 49 = 83
It can be proved that you can't modify any letter such that a better result is procedured.
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6517

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

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 65536/65536K(Java/Others)