Codeforces Round 516 (Div. 1, by Moscow Team Olympiad)
F
String Journey
Codeforces
3300
原题
← E→
翻译中…

We call a sequence of strings $*t*_{1}, ..., *t*_{*k*}$ a journey of length $*k*$, if for each $*i* > 1$ $*t*_{*i*}$ is a substring of $*t*_{*i* - 1}$ and length of $*t*_{*i*}$ is strictly less than length of $*t*_{*i* - 1}$. For example, ${*ab*, *b*}$ is a journey, but ${*ab*, *c*}$ and ${*a*, *a*}$ are not.

翻译中…

Define a journey on string $*s*$ as journey $*t*_{1}, ..., *t*_{*k*}$, such that all its parts can be nested inside $*s*$ in such a way that there exists a sequence of strings $*u*_{1}, ..., *u*_{*k* + 1}$ (each of these strings can be empty) and $*s* = *u*_{1} *t*_{1} *u*_{2} *t*_{2}... *u*_{*k*} *t*_{*k*} *u*_{*k* + 1}$. As an example, ${*ab*, *b*}$ is a journey on string $*abb*$, but not on $*bab*$ because the journey strings $*t*_{*i*}$ should appear from the left to the right.

翻译中…

The length of a journey on a string is the number of strings in it. Determine the maximum possible length of a journey on the given string $*s*$.

翻译中…

Input

翻译中…

The first line contains a single integer $*n*$ ($1 ≤ *n* ≤ 500 000$) — the length of string $*s*$.

翻译中…

The second line contains the string $*s*$ itself, consisting of $*n*$ lowercase Latin letters.

翻译中…

Output

翻译中…

Print one number — the maximum possible length of string journey on $*s*$.

翻译中…

Note

翻译中…

In the first sample, the string journey of maximum length is ${*abcd*, *bc*, *c*}$.

翻译中…

In the second sample, one of the suitable journeys is ${*bb*, *b*}$.

翻译中…

样例

Input #1
7
abcdbcc
Output #1
3
InputCopy OutputCopy
Input #2
4
bbcb
Output #2
2
InputCopy OutputCopy
题目信息
题号
1063F
时间限制
5 s
内存限制
512 MB
标签
数据结构
动态规划
后缀结构

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。