|
||||||||||
ReincarnationTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 7007 Accepted Submission(s): 2816 Problem Description Now you are back,and have a task to do: Given you a string s consist of lower-case English letters only,denote f(s) as the number of distinct sub-string of s. And you have some query,each time you should calculate f(s[l...r]), s[l...r] means the sub-string of s start from l end at r. Input The first line contains integer T(1<=T<=5), denote the number of the test cases. For each test cases,the first line contains a string s(1 <= length of s <= 2000). Denote the length of s by n. The second line contains an integer Q(1 <= Q <= 10000),denote the number of queries. Then Q lines follows,each lines contains two integer l, r(1 <= l <= r <= n), denote a query. Output For each test cases,for each query,print the answer in one line. Sample Input
Sample Output
Hint I won't do anything against hash because I am nice.Of course this problem has a solution that don't rely on hash. Author WJMZBMR Source | ||||||||||
|