#P10233. Dance Dance DX Scoring
Dance Dance DX Scoring
Dance Dance DX Scoring
In the game 舞萌 DX, each note is judged at the moment it is hit. There are five possible judgments with the following abbreviations and dx score contributions:
Critical Perfect
(abbreviated asP
): yields $3$ dx points.Perfect
(abbreviated asp
): yields $2$ dx points.Great
(abbreviated asG
): yields $1$ dx point.Good
(abbreviated asg
): yields $0$ dx points.Miss
(abbreviated asm
): yields $0$ dx points.
Fu Su recorded the judgment sequence of a song in a string s
where the leftmost character corresponds to the first note and the rightmost to the last note. The number of notes is $|s|$, the length of the string.
You are given $q$ queries. Each query consists of two integers $l$ and $r$, and you need to compute the total dx score for the segment of notes from the $l$-th to the $r$-th (inclusive). The score is the sum of the dx points for each note in that segment.
inputFormat
The input consists of multiple lines. The first line contains the string s
representing the judgment results. The second line contains an integer q
denoting the number of queries. Each of the following q
lines contains two integers l
and r
separated by a space, indicating the starting and ending positions of the note segment (1-indexed).
outputFormat
For each query, output a single integer on a new line representing the total dx score of the notes between indices l
and r
(inclusive).
sample
PpGgm
3
1 1
2 3
1 5
3
3
6
</p>