P6456 [COCI 2006/2007 #5] DVAPUT

Description

Given a string of length $L$, you need to find the longest substring that appears at least twice in the string (at different positions). Output its length.

Input Format

The first line contains an integer $L$, representing the length of the string. The second line contains a string of length $L$.

Output Format

Output one line containing one integer, representing the length of this longest substring.

Explanation/Hint

#### Constraints For $100\%$ of the testdata, it is guaranteed that $1 \le L \le 2 \times 10^5$, and the input string consists only of lowercase letters. #### Notes **This problem is translated from [COCI2006-2007](https://hsin.hr/coci/archive/2006_2007/) [CONTEST #5](https://hsin.hr/coci/archive/2006_2007/contest5_tasks.pdf) *T6 DVAPUT***. Translated by ChatGPT 5