#x1005. CF914F Substrings in a String
CF914F Substrings in a String
Substrings in a String
题面翻译
题目描述
给你一个字符串 ,共有 次操作,每个都是下面两种形式的一种。
1 i c
:将字符串 的第 项变为字符 。2 l r y
:求字符串 在字符串 中以第 项为起点,以第 项为终点的子串(第 和第 项)中作为子串出现的次数。
,,。
题目描述
Given a string , process queries, each having one of the following forms:
- — Change the -th character in the string to .
- — Consider the substring of starting at position and ending at position . Output the number of times occurs as a substring in it.
输入格式
The first line of the input contains the string ( ) of lowercase English letters.
The second line contains an integer ( ) — the number of queries to process.
The next lines describe the queries and may have one of the following forms:
- ( )
- ( )
is a lowercase English letter and is a non-empty string consisting of only lowercase English letters.
The sum of over all queries of second type is at most .
It is guaranteed that there is at least one query of second type.
All strings are -indexed.
is the length of the string .
输出格式
For each query of type , output the required answer in a separate line.
样例 #1
样例输入 #1
ababababa
3
2 1 7 aba
1 5 c
2 1 7 aba
样例输出 #1
3
1
样例 #2
样例输入 #2
abcdcbc
5
2 1 7 bc
1 4 b
2 4 7 bc
1 2 a
2 1 4 aa
样例输出 #2
2
2
1
提示
Consider the first sample case. Initially, the string aba occurs times in the range . Note that two occurrences may overlap.
After the update, the string becomes ababcbaba and now aba occurs only once in the range .