Queries are not locks
InterviewTime limit2sMemory limit1024 MB
Given a string with single-character updates, answer range queries for the number of subsequences equal to ROCK, modulo 1000000007.
- Level
Medium5 of 10
- Topics
- Segment tree, Dynamic programming, String
- Solved
- No attempts yet
Problem
Na-rak is a lock, a call from your parents is a lock, and 오락가락? is a lock?, but sadly a query is not a lock.
You are given a string of length made of uppercase English letters. Process queries of the following kinds.
- : Change to . is an uppercase English letter
- : Print the number of subsequences of that end with
ROCK. Since the count can be very large, print it modulo .
Input
The first line contains the length of the string .
The second line contains the string , which consists only of uppercase English letters.
The third line contains the number of queries .
The next lines contain the queries. The last query given is a type 2 query.
Output
For each type 2 query, print the answer on its own line.
Hint
A subsequence of a string is a string obtained by deleting zero or more characters from it. For example, aan is a subsequence of hanyang.