String Journey

题意翻译

对于一个字符串数组 $t_1, \ldots, t_k$,若对于每一个 $t_i$ 都是 $t_{i-1}$ 的真子串的话,即 $t_i$ 是 $t_{i - 1}$ 的子串且 $t_i \ne t_{i-1}$,则称为有序串组,列如 $\{\mathtt{ab}, \mathtt{b}\}$ 是,$\{\mathtt{ab}, \mathtt{c}\}$ 和 $\{ \mathtt{a}, \mathtt{a}\}$ 不是。 给定字符串 $s$,构造有序串组 $t_1,\ldots,t_k$ 和任意字符串数组 $u_1,\ldots,u_{k+1}$,使 $s=u_1+t_1+u_2+t_2 + \cdots +t_k+u_{k+1}$,其中 $+$ 为字符串的拼接 现在给定一个字符串,求满足条件的最大 $k$。 输入格式: 一个字符串 $s$ 输出格式: 一个整数 $k$

题目描述

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 $ .

输入输出格式

输入格式


The first line contains a single integer $ n $ ( $ 1<=n<=500000 $ ) — the length of string $ s $ . The second line contains the string $ s $ itself, consisting of $ n $ lowercase Latin letters.

输出格式


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

输入输出样例

输入样例 #1

7
abcdbcc

输出样例 #1

3

输入样例 #2

4
bbcb

输出样例 #2

2

说明

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} $ .