luogu#P4482. [BJWC2018] Border 的四种求法
[BJWC2018] Border 的四种求法
Background
As soon as Scape walked into the computer lab, everyone solving problems looked at him and laughed. Someone shouted, "Scape, you must have been crushed by the standard score again!" He did not answer; he said, "Run two programs, check the score sheet," and then he copied out two programs. They deliberately shouted again, "How did you get WA on both the Euler circuit and inversions?" ...
Problem Description
Scape knows that the story above is just an accident in his OI career. To prove himself, he decides to teach you four methods to compute .
Given a lowercase-letter string , there are queries. Each query gives , and asks for the of .
: For a given string , the largest such that . Here is the length of .
Input Format
The first line contains a string .
The second line contains an integer denoting the number of queries.
Each of the next lines contains two integers denoting a query.
Output Format
For each query, output the answer.
abbabbaa
3
1 8
1 7
2 7
1
4
3
Hint
- For of the testdata, .
- For of the testdata, .
- For another of the testdata, the answer is at least half of .
- For of the testdata, .
Translated by ChatGPT 5