atcoder#ABC122C. [ABC122C] GeT AC
[ABC122C] GeT AC
Score : points
Problem Statement
You are given a string of length consisting of A
, C
, G
and T
. Answer the following queries:
- Query (): You will be given integers and (). Consider the substring of starting at index and ending at index (both inclusive). In this string, how many times does
AC
occurs as a substring?
Notes
A substring of a string is a string obtained by removing zero or more characters from the beginning and the end of .
For example, the substrings of ATCODER
include TCO
, AT
, CODER
, ATCODER
and `` (the empty string), but not AC
.
Constraints
- is a string of length .
- Each character in is
A
,C
,G
orT
.
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the answer to the -th query.
8 3
ACACTACG
3 7
2 3
1 8
2
0
3
- Query : the substring of starting at index and ending at index is
ACTAC
. In this string,AC
occurs twice as a substring. - Query : the substring of starting at index and ending at index is
CA
. In this string,AC
occurs zero times as a substring. - Query : the substring of starting at index and ending at index is
ACACTACG
. In this string,AC
occurs three times as a substring.