Consecutive
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
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:
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,
ssissip
has two places where the same lowercase English letter occurs twice in a row:ss
andss
. - For the second query,
sissipp
has two places where the same lowercase English letter occurs twice in a row:ss
andpp
. - For the third query,
sis
has zero places where the same lowercase English letter occurs twice in a row. - For the fourth query,
s
has zero places where the same lowercase English letter occurs twice in a row.