You are given a text formed by N characters (lower or upper case letters and digits). A substring of the text is a sequence of characters which appear on continuous positions in the text. Task: Given a number K, determine the length of the longest substring which appears in the text at least K times. Entry data: The file substr.in will contain on the first line the numbers N and K, separated with a space. The second line is a text formed by N characters, without spaces, ending with a newline. Output data: The file substr.out should contain only one line, having printed the max length of the substring which appears at least K times in the text. Restrictions: 1 <= N <= 16.384 1 <= K <= N For 30% of the tests, N <= 1.000 Example: substr.in
substr.out
Explanation: The substring ba appears three times in the text. Any substring of a bigger length (like aba) appears less than three times. |