All submissions for this problem are available.
Dhruv is full of cunning and deceitful tricks.
Students from his hostel went to him to learn some of his famous tricks. Since Dhruv does not want to share it with many people, his wicked brain comes up with an idea. He will teach his tricks only to that person who comes up with the first successful submission.
Your task is to solve his query as fast as possible.
Given a string P, consisting only of lower case alphabets.You need to answer q queries each of which is of the format a L R. For a given query, Chef wants to count the frequency of the character a from the Lth index to the Rth index, both indexes being inclusive. The string is 1 indexed.
Note: Use fast i/o techniques.
First line of the input contains a string P denoting the string. Next line of the input contains a single integer Q denoting the number of queries. Next Q lines of the input contains three space separated parameters where the first parameter is the character denoting a and rest two are integers denoting L and R respectively..
For each query, print the required answer.
- 1 <= |P| <= 106
- 1 <= Q <= 106
- 1 <= L <= R <= |P|
Input: dhruvisevil 3 d 1 4 i 6 10 s 2 9 Output: 1 2 1
|Time Limit:||1 - 3 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions