cswork / OA打开练习工作台

IBMOA #29

Get Max Occurrences

估计中等可在线判题

考点(AI 标注)哈希计数双指针滑窗

Find the maximum number of times a substring occurs in the original string; occurrences may overlap. Candidate lengths are between minLength and maxLength, and the number of distinct characters must not exceed maxUnique; output 0 if there is no valid candidate.

输入格式

The first line contains minLength maxLength maxUnique, and the second line contains the string. Original bounds: 2≤length≤100000, 2≤minLength≤maxLength≤26 and maxLength<string length, 2≤maxUnique≤26. The source does not restrict the character set; this site supports non-newline Unicode scalar characters, each character counts as one code point, and the total UTF-8 size is ≤400100 bytes.

输出格式

Output one integer, the answer.

样例 1

输入:

2 4 2
abcde

输出:

1

样例 2

输入:

2 3 2
ababab

输出:

3

样例 3

输入:

2 3 2
aaaa

输出:

3

样例说明

The examples give 1, 3 and 3 respectively; ab occurs 3 times in ababab, and occurrences of aa may overlap.