A10530 | Cool Slogans
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted