#P4465. [国家集训队] JZPSTR
[国家集训队] JZPSTR
Description
You need to perform three types of operations on a string: 0. Insert a string at position .
- Delete the substring in the interval .
- Query how many times a given substring occurs in the substring of the interval .
The indices of the string start from (that is, the first character has index ).
Initially, the string is empty.
For the insertion operation, after insertion the first character of should have index . For the deletion operation, the interval is a left-closed, right-open interval. For the query operation, the interval is a left-closed, right-open interval.
All inserted strings and query strings are non-empty and contain only characters .
All query intervals and deletion intervals are non-empty.
The input is guaranteed to be valid.
If you do not understand the term "left-closed, right-open interval", please see the sample explanation.
Input Format
The first line contains an integer , the number of operations.
In the following lines, the first number indicates the type of the operation:
- If , then an integer and a string follow, indicating an insertion.
- If , then two integers and follow, indicating a deletion.
- If , then two integers and , and a string follow, indicating a query.
Output Format
For each query operation, output one line with the answer to that query.
8
0 0 894894894
2 0 2 894
2 0 9 894
0 2 6
2 0 9 64
2 0 9 894
1 2 6
2 0 6 894
0
3
1
1
2
Hint
Sample explanation:
- After the first operation, the string is .
- In the second operation, the queried interval is , which contains no .
- In the third operation, the queried interval is , which contains three .
- After the fourth operation, the string is .
- In the fifth operation, the queried interval is , which contains one .
- In the sixth operation, the queried interval is , which contains one .
- After the seventh operation, the string is .
- In the eighth operation, the queried interval is , which contains two .
Constraints:
- In of the testdata, the number of queries (not the number of operations).
- In of the testdata, the total inserted length , the string length at any time , the number of insertions , the number of deletions , and the total length of all queried .
Source: 2012 CTT internal contest, by gyz.
Translated by ChatGPT 5
京公网安备 11011102002149号