#P4482. [BJWC2018] Border 的四种求法
[BJWC2018] Border 的四种求法
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
京公网安备 11011102002149号