CF1789F Serval and Brain Power
题目描述
定义一个字符串 $T$ 是好的,当且仅当存在字符串 $T'$ 和整数 $k(k\geq2)$,使得 $T$ 可以由 $k$ 个 $T'$ 首尾相接得到。
例如,字符串 $\texttt{gogogo}$ 就是好的,因为它可以由 $3$ 个字符串 $\texttt{go}$ 首尾相接得到;而 $\texttt{power}$ 就不是好的。
给定仅包含小写英文字母的字符串 $S$。
你需要求出 $S$ 最长的好的子序列(不一定连续)的长度,特别的如果 $S$ 没有好的子序列,答案为 $0$。
输入格式
无
输出格式
无
说明/提示
For the first sample, all of the non-empty subsequences of buaa are listed below:
- b
- u
- a (occurred twice, buaa and buaa)
- bu
- ba (occurred twice, buaa and buaa)
- ua (occurred twice, buaa and buaa)
- aa
- bua (occurred twice, buaa and buaa )
- baa
- uaa
- buaa
Since $ \texttt{aa} = \texttt{a} + \texttt{a} $ , aa is a powerful subsequence. It can be shown that aa is the only powerful subsequence among them. So the answer is $ 2 $ .
For the second sample, the longest powerful subsequence is codcod from codeforcesround. So the answer is $ 6 $ .