#C5717. Dynamic String Query Processing
Dynamic String Query Processing
Dynamic String Query Processing
You are given a string s consisting of lowercase English letters, a set of characters T which is a subset of the English alphabet, and Q queries. There are two types of queries:
- Type 1: Given two integers l and r (1-indexed), count the occurrences of characters from T in the substring s[l:r] (inclusive). The answer for this query should be printed on a new line.
- Type 2: Given an integer v and a character c, replace the character at the v-th position in s with c.
You are to process the queries in the given order. For each type 1 query, output the resulting count. Recall that the indices are 1-indexed. The following latex formula shows the conversion from 1-indexed to 0-indexed: \[ index_{0} = index_{1} - 1 \]
Note: The input should be read from standard input and the output should be written to standard output.
inputFormat
The input is given via standard input in the following format:
- The first line contains the string s.
- The second line contains the string T, representing the set of characters.
- The third line contains an integer Q, the number of queries.
- The next Q lines each represent a query. Each query is formatted as follows:
- If the query is of type 1, the line will contain:
1 l r
- If the query is of type 2, the line will contain:
2 v c
- If the query is of type 1, the line will contain:
outputFormat
For each type 1 query, output the count of characters from T in the specified substring. Each answer should be printed on a new line.
## sampleabcabcabc
ab
5
1 1 3
2 2 d
1 1 3
2 5 e
1 1 5
2
1
2
</p>