luogu#P3732. [HAOI2017] 供给侧改革
[HAOI2017] 供给侧改革
Background
Description
You investigated the supply-demand balance of an industry over the past periods. Each period is represented by a single digit, either or . Thus, this forms a string of length . To better understand the data, you need to answer several queries. Let denote: among all suffixes of whose starting positions lie in , the length of the longest common prefix of the two suffixes that achieve the maximum common prefix.
For each query , compute:
It is guaranteed that each character of is randomly generated as or .
Output Format
Output lines, each containing a single integer, the answer to the corresponding query.
6 3
010110
2 5
1 6
1 2
4
6
0
Hint
[Constraints and Notes]
| Data Point | Scale of | Scale of |
|---|---|---|
For all testdata, it is guaranteed that , , , and the string is randomly generated.
Translated by ChatGPT 5