Cool Slogans
题意翻译
给定一个字符串 $S$,要求构造字符串序列 $s_1,s_2,\ldots,s_k$,满足任意 $s_i$ 都是 $S$ 的子串,且任意 $i\in[2,n]$,都有 $s_{i-1}$ 在 $s_i$ 中出现了至少 $2$ 次(可以有重叠部分,只要起始、结尾位置不同即可)。
求可能的最大的 $k$ 的值(即序列的最大可能长度)。
$n \leq 2 \times 10^5$。
题目描述
Bomboslav set up a branding agency and now helps companies to create new logos and advertising slogans. In term of this problems, slogan of the company should be a non-empty substring of its name. For example, if the company name is "hornsandhoofs", then substrings "sand" and "hor" could be its slogans, while strings "e" and "hornss" can not.
Sometimes the company performs rebranding and changes its slogan. Slogan $ A $ is considered to be cooler than slogan $ B $ if $ B $ appears in $ A $ as a substring at least twice (this occurrences are allowed to overlap). For example, slogan $ A= $ "abacaba" is cooler than slogan $ B= $ "ba", slogan $ A= $ "abcbcbe" is cooler than slogan $ B= $ "bcb", but slogan $ A= $ "aaaaaa" is not cooler than slogan $ B= $ "aba".
You are given the company name $ w $ and your task is to help Bomboslav determine the length of the longest sequence of slogans $ s_{1},s_{2},...,s_{k} $ , such that any slogan in the sequence is cooler than the previous one.
输入输出格式
输入格式
The first line of the input contains a single integer $ n $ ( $ 1<=n<=200000 $ ) — the length of the company name that asks Bomboslav to help. The second line contains the string $ w $ of length $ n $ , that consists of lowercase English letters.
输出格式
Print a single integer — the maximum possible length of the sequence of slogans of the company named $ w $ , such that any slogan in the sequence (except the first one) is cooler than the previous
输入输出样例
输入样例 #1
3
abc
输出样例 #1
1
输入样例 #2
5
ddddd
输出样例 #2
5
输入样例 #3
11
abracadabra
输出样例 #3
3