#P8451. [LSOT-1] Crosspain
[LSOT-1] Crosspain
Background

Problem Description
Let . Maintain a data structure that supports the following operations:
1 hoc s: Let , where is a string (it is guaranteed that before the operation ).2 hoc s: Let , and query the sum of the number of occurrences of all strings in within the given string .
Input Format
The first line contains a positive integer , indicating the number of queries.
The next lines each contain one operation, in the format described above.
Output Format
For each operation 2, output one line containing the answer.
5
1 0 abc
2 0 abc
1 2 def
2 3 defg
2 1 abcd
0
1
1
Hint
Sample Explanation
In the third line, we ask how many times the strings in version appear in abc. Since version is empty, it appears times.
In the fifth line, we ask how many times the strings in version appear in defg. Since version contains the string def, it appears time.
In the sixth line, we ask how many times the strings in version appear in abcd. Since version contains the string abc, it appears time.
Constraints and Notes
"This problem uses bundled testdata."
- $\texttt{Subtask 1(10 pts):} \displaystyle \sum|s_i|\le 1000$.
- All added strings have the same length.
- All added strings contain only one kind of character.
- .
- No special restrictions.
For all testdata, , . All strings contain only lowercase letters.
Translated by ChatGPT 5