[ABC328C] 连续相同字符统计 (Consecutive)
Score : points
Problem Statement
You are given a string of length consisting of lowercase English letters.
Additionally, you are given queries about the string . For , the -th query is represented by two integers and asks the following.
In the substring of , which ranges from the -th to the -th character, how many places are there where the same lowercase English letter occurs twice in a row? In other words, how many integers satisfy and ?
Print the answer for each of the queries.
Constraints
-
and are integers.
-
-
is a string of length consisting of lowercase English letters.
-
and are integers.
-
Input
The input is given from Standard Input in the following format:
$N$ $Q$
$S$
$l_1$ $r_1$
$l_2$ $r_2$
$\vdots$
$l_Q$ $r_Q$
Output
Print lines. For , the -th line should contain the answer to the -th query.
Sample Input 1
11 4
mississippi
3 9
4 10
4 6
7 7
Sample Output 1
2
2
0
0
The answers to the four queries are as follows.
-
For the first query,
ssissiphas two places where the same lowercase English letter occurs twice in a row:ssandss. -
For the second query,
sissipphas two places where the same lowercase English letter occurs twice in a row:ssandpp. -
For the third query,
sishas zero places where the same lowercase English letter occurs twice in a row. -
For the fourth query,
shas zero places where the same lowercase English letter occurs twice in a row.
Sample Input 2
5 1
aaaaa
1 5
Sample Output 2
4
aaaaa has four places where the same lowercase English letter occurs twice in a row:
aa, aa, aa, and aa.