#Q40. 「一本通 2.1 练习 4」A Horrible Poem
「一本通 2.1 练习 4」A Horrible Poem
Description
Original source: POI 2012
Given a string consisting of lowercase English letters, and queries, each query asks for the length of the shortest cycle in a substring of .
A string is a cycle of string if can be formed by repeating multiple times.
Input Format
The first line contains a positive integer , the length of .
The second line contains lowercase English letters, representing the string .
The third line contains a positive integer , the number of queries.
The following lines each contain two positive integers and , representing the query for the substring and asking for the length of its shortest cycle.
Output Format
Output lines of positive integers, where the -th line corresponds to the answer for the -th query.
Sample 1
8
aaabcabc
3
1 3
3 8
4 8
1
3
5
Constraints and Hints
.
Related
In following homework: