#P9997. [Ynoi2000] pmpkmp
[Ynoi2000] pmpkmp
Problem Description
Given a tree, each edge of the tree has a character on it. A constant is given.
There are two types of operations. Each operation inputs three integers and a string:
1 x y S: For the edges on the directed simple path from to , replace the character on the -th edge of the path with the corresponding character in . It is guaranteed that the number of edges on the path from to is .
2 x y S: Query the number of matches of on the string formed by the directed simple path from to (here, matching means: treat as the pattern string and match it against the path string position by position). For example, if and the path string is , then it matches 2 times, at positions and .
For all strings above, indices start from . It is guaranteed that the length of every input string is .
Input Format
The first line contains three integers separated by spaces.
The next line contains integers. The -th integer denotes the parent of node . It is guaranteed that the parent index of each node is smaller than the node index.
The next line contains characters. The -th character denotes the character on the edge from node to its parent.
Then follow lines. Each line contains three integers separated by spaces and a string of length , representing one operation.
Output Format
Output a total of lines. Each line contains one integer, representing the answer to each operation of type .
10 7 2
1 2 3 2 3 3 3 3 7
212111121
2 1 4 21
1 10 3 21
1 9 7 22
2 2 10 12
2 6 8 11
1 9 8 12
2 4 7 11
1
1
1
0
Hint
Idea: nzhtl1477, Solution: ComeIntoPower&nzhtl1477&ccz181078, Code: ccz181078, Data: ccz181078.
Constraints:
For of the testdata, .
For another of the testdata, there are no type operations.
For another of the testdata, .
For another of the testdata, .
For another of the testdata, .
For another of the testdata, .
For another of the testdata, .
For another of the testdata, , and .
For another of the testdata, , and .
For of the testdata, . The alphabet consists of integers in , and .
Translated by ChatGPT 5