#P6292. 区间本质不同子串个数
区间本质不同子串个数
Problem Description
Given a string of length consisting only of lowercase letters, there are queries. Each query asks how many essentially different non-empty substrings are contained in the string formed by the -th to the -th characters of .
Two strings are defined to be the same if and only if and for all , we have .
Input Format
The first line contains a string of length .
The second line contains an integer , indicating the number of queries.
The next lines each contain two integers , describing the -th query.
Output Format
Output lines, each containing an integer, representing the answer to the -th query.
aababc
3
1 2
2 4
3 6
2
5
9
Hint
Explanation for Sample 1
- For the first query, the string is , and it contains and , for a total of essentially different substrings.
- For the second query, the string is , and it contains $\texttt{a},\texttt{b},\texttt{ab},\texttt{ba},\texttt{aba}$, for a total of essentially different substrings.
- For the third query, the string is , and it contains ,,,,,,,,, for a total of essentially different substrings.
Constraints
- For of the testdata, and .
- For of the testdata, , , .
Translated by ChatGPT 5