401363: GYM100418 C Substrings
Memory Limit:64 MB
Time Limit:3 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
C. Substringstime limit per test3 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard output
You are given a string S consisting of capital Latin letters. Consider the queries consisting of pairs of integer numbers Li and Ri. For each of them you should find the number of substrings which are less than substring S[Li...Ri].
InputThe first line contains the string S(1 ≤ |S| ≤ 105). The second line contains the number N (1 ≤ N ≤ 105), denoting the number of queries. The next N lines contain pairs of numbers Li, Ri (1 ≤ Li ≤ Ri ≤ |S|).
OutputFor each query you should output the number of substrings which satisfy specified conditions.
ExamplesInputBSUIROPENPROGRAMMINGCHAMPIONSHIPOutput
1
1 15
42