CF1063F.String Journey

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

We call a sequence of strings t1,...,tkt_{1},...,t_{k} a journey of length kk , if for each i>1i>1 tit_{i} is a substring of ti1t_{i-1} and length of tit_{i} is strictly less than length of ti1t_{i-1} . For example, ab,b{ab,b} is a journey, but ab,c{ab,c} and a,a{a,a} are not.

Define a journey on string ss as journey t1,...,tkt_{1},...,t_{k} , such that all its parts can be nested inside ss in such a way that there exists a sequence of strings u1,...,uk+1u_{1},...,u_{k+1} (each of these strings can be empty) and s=u1t1u2t2... uktkuk+1s=u_{1}t_{1}u_{2}t_{2}...\ u_{k}t_{k}u_{k+1} . As an example, ab,b{ab,b} is a journey on string abbabb , but not on babbab because the journey strings tit_{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 ss .

输入格式

The first line contains a single integer nn ( 1<=n<=5000001<=n<=500000 ) — the length of string ss .

The second line contains the string ss itself, consisting of nn lowercase Latin letters.

输出格式

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

输入输出样例

  • 输入#1

    7
    abcdbcc
    

    输出#1

    3
    
  • 输入#2

    4
    bbcb
    

    输出#2

    2
    

说明/提示

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

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

首页