P14690 [CodeChef] TOTCARS
普及
题目描述

There are total $N$ cars in a sequence with $ith$ car being assigned with an alphabet equivalent to the $ith$ alphabet of string $S$ . Chef has been assigned a task to calculate the total number of cars with alphabet having a unique even value in the given range X to Y (both inclusive)
. The value of an alphabet is simply its position in alphabetical order e.g.: a=1, b=2, c=3…
The chef will be given $Q$
such tasks having varying values of $X$ and $Y$
Note: string $S$ contains only lowercase alphabets

-----Input-----
First line of input contains a string $S$ of length $N$.
Second line contains an integer denoting no. of queries $Q$.
Next q lines contain two integers denoting values of $X$ and $Y$.

-----Output-----
For each query print a single integer denoting total number of cars with alphabet having a unique even value in the given range $X$ to $Y$.

-----Constraints-----
- $1 \leq n \leq 10^5$
- $1 \leq q \leq 10^5$

-----Example Input-----
bbccdd
5
1 2
3 4
5 6
1 6
2 5

-----Example Output-----
1
0
1
2
2

-----Explanation:-----
Example case 1:
Query 1: range 1 to 2 contains the substring $"bb"$ where each character has a value of 2. Since we will only be considering unique even values, the output will be 1

输入格式

见题面

输出格式

见题面

样例输入
['bbccdd', '5', '1 2', '3 4', '5 6', '1 6', '2 5']
样例输出
['1', '0', '1', '2', '2']