PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000047. Đếm chuỗi con khi sửa ký tự
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm chuỗi con khi sửa ký tự
Substrings in a String
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given a lowercase English string , process operations:
1 i c: change character at index toc.2 l r y: count all occurrences of the non-empty pattern that lie entirely within the inclusive substring .
An occurrence starting at is valid if and , and every character matches. Overlapping occurrences are counted. If the pattern is longer than the query interval, the answer is zero. The sum of all queried pattern lengths is at most .
Input
The first line contains , the second contains , followed by lines of 1 i c or 2 l r y.
Output
Output one occurrence count per type-2 query.
Subtasks
- Subtask 1 (10 points): ; ; The sum of the lengths of all type-
2query patterns is at most . - Subtask 2 (20 points): ; ; The sum of the lengths of all type-
2query patterns is at most . - Subtask 3 (30 points): ; ; The sum of the lengths of all type-
2query patterns is at most . - Subtask 4 (40 points): ; ; The sum of the lengths of all type-
2query patterns is at most .
Examples
Input
ababababa
3
2 1 7 aba
1 5 c
2 1 7 aba
Output
3
1
Explanation
In ababababa, pattern aba occurs fully in positions starting at , for a total of . Replacing the fifth character with c leaves only one occurrence in that interval.