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

建议使用的浏览器:

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

6894:CCPC Training Class

题目描述
Baby volcano is helping his CCPC coach preparing a new CCPC training contest. He wants to generate high quality data on border tree(There is no need to know what border tree is), but he encounters some troubles. Could you please help him?

In this paragraph we formally define the data quality problem. For some string $s = s_1s_2s_3\cdots s_n$, we use $s[l:r]$ to denote the substring starts from $l$ and ends at $r$, if $l>r$, $s[l:r]$ is empty. We further define:
$$Lborder_i = \max\{0\leq j < i\ |\ s[1:j] = s[i-j+1:i]\}$$
to denote the longest border at some position $i$, then we define $D(i)$ to denote the length of border chain at position $i$:
$$D(i) = \begin{cases} 0 & i=0 \\ D(LBorder_i) + 1 & i > 0 \end{cases}$$
The quality $W$ of this string is define as the maximum of $D$:
$$W = \max_{i = 0}^{n} D(i)$$

To distinguish border tree with naive brute force algorithms, baby volcano need to generate strings such that its quality $W$ is as large as possible.

Now given a string $s$, you could permute $s$ arbitrarily. What is the maximum quality $W$ you could reach after permuting $s$?
输入解释
In the first line there is a number $T$($T\leq 20$), denotes the number of test cases.
In the next $T$ lines, for each line there is a string $s$($1\leq |s|\leq 10^5$), denotes the input string, all inputs are formed in lowercases.
输出解释
Output $T$ lines, for each line, you need to output ''Case #t: m''(without quotes), where t is the index of this test case, m is the maximum quality you could reach after permuting.
输入样例
5
abcde
sankaranarayanan
abbccaabc
programming
monotone
输出样例
Case #1: 1
Case #2: 7
Case #3: 3
Case #4: 2
Case #5: 3
来自杭电HDUOJ的附加信息
Recommend IceyWang

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

源链接: HDU-6894

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

共提交 0

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