Codecraft-18 and Codeforces Round 458 (Div. 1 + Div. 2, combined)
F
Substrings in a String
Codeforces
3000
原题
← EG →
翻译中…

Given a string $*s*$, process $*q*$ queries, each having one of the following forms:

翻译中…
  • $1 *i* *c*$ — Change the $*i*$-th character in the string to $*c*$.
  • $2 *l* *r* *y*$ — Consider the substring of $*s*$ starting at position $*l*$ and ending at position $*r*$. Output the number of times $*y*$ occurs as a substring in it.
翻译中…

Input

翻译中…

The first line of the input contains the string $*s*$ ($1 ≤ |*s*| ≤ 10^{5}$) of lowercase English letters.

翻译中…

The second line contains an integer $*q*$ ($1 ≤ *q* ≤ 10^{5}$)  — the number of queries to process.

翻译中…

The next $*q*$ lines describe the queries and may have one of the following forms:

翻译中…
  • $1 *i* *c*$ ($1 ≤ *i* ≤ |*s*|$)
  • $2 *l* *r* *y*$ ($1 ≤ *l* ≤ *r* ≤ |*s*|$)
翻译中…

$*c*$ is a lowercase English letter and $*y*$ is a non-empty string consisting of only lowercase English letters.

翻译中…

The sum of $|*y*|$ over all queries of second type is at most $10^{5}$.

翻译中…

It is guaranteed that there is at least one query of second type.

翻译中…

All strings are $1$-indexed.

翻译中…

$|*s*|$ is the length of the string $*s*$.

翻译中…

Output

翻译中…

For each query of type $2$, output the required answer in a separate line.

翻译中…

Note

翻译中…

Consider the first sample case. Initially, the string aba occurs $3$ times in the range $[1, 7]$. Note that two occurrences may overlap.

翻译中…

After the update, the string becomes ababcbaba and now aba occurs only once in the range $[1, 7]$.

翻译中…

样例

Input #1
ababababa
3
2 1 7 aba
1 5 c
2 1 7 aba
Output #1
3
1
InputCopy OutputCopy
Input #2
abcdcbc
5
2 1 7 bc
1 4 b
2 4 7 bc
1 2 a
2 1 4 aa
Output #2
2
2
1
InputCopy OutputCopy
题目信息
题号
914F
时间限制
6 s
内存限制
256 MB
标签
位运算
暴力
数据结构
后缀结构
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。