#P8617. [蓝桥杯 2014 国 AC] 重复模式

[蓝桥杯 2014 国 AC] 重复模式

Description

As drd’s good friend, the tech guy atm gave him a very long string SS as a birthday present. atm asks drd to find a longest string TT such that TT appears in SS at least twice, and the secret he wants to tell is hidden in TT.

Because the string is too long, drd can never find a suitable TT. So drd asks you to help find the length of this TT.

Input Format

One line. A string, which is SS mentioned in the statement.

Output Format

One line. An integer, representing the length of the longest TT.

ababa
3

Hint

For 30%30\% of the testdata, the length of SS is 100\le 100.

For 60%60\% of the testdata, the length of SS is 8000\le 8000.

For 100%100\% of the testdata, the length of SS is 500000\le 500000.

Time limit: 1 second, 256M. Lanqiao Cup 2014, the 5th National Final.

Translated by ChatGPT 5