luogu#P6456. [COCI 2006/2007 #5] DVAPUT

    ID: 5478 远端评测题 1000ms 32MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>2006二分哈希 hashing后缀数组 SACOCI(克罗地亚)

[COCI 2006/2007 #5] DVAPUT

Problem Description

Given a string of length LL, 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 LL, representing the length of the string.

The second line contains a string of length LL.

Output Format

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

11
sabcabcfabc
3
18
trutrutiktiktappop
4
6
abcdef
0

Hint

Constraints

For 100%100\% of the testdata, it is guaranteed that 1L2×1051 \le L \le 2 \times 10^5, and the input string consists only of lowercase letters.

Notes

This problem is translated from COCI2006-2007 CONTEST #5 T6 DVAPUT.

Translated by ChatGPT 5