#P7582. 「RdOI R2」风雨(rain)
「RdOI R2」风雨(rain)
Description
During this period, Little Soup recorded meaningful things, and represented them with strings. The -th thing is represented as , and its value is defined as . Next, Little Soup will perform operations.
Operation 1: Little Soup adds a constant to all in the interval .
Operation 2: Little Soup assigns all in the interval to a constant .
Operation 3: Little Soup gives a memory, which forms a string . He wants to know how meaningful is within the interval . Let be the number of occurrences of in . Then the meaning of in the interval is .
Input Format
The first line contains two integers .
The next lines: the -th line contains a string and an integer .
The next lines: each line describes one operation, starting with three integers , where denotes the operation type. When , an additional string is given; otherwise, an additional integer is given.
Output Format
For each operation of type , output one integer, representing the total value.
3 4
ab 1
ba 2
a 1
3 1 3 aba
1 1 2 1
2 2 3 2
3 1 2 abab
5
6
6 6
aba 3
ba 2
aa 2
c 1
abac 4
ab 2
3 2 5 abac
2 3 5 3
3 4 6 abc
1 2 3 1
3 1 3 aabaa
3 2 5 aabac
7
5
14
13
6 3
b 1
aa 8
cc 9
cac 8
ab 10
a 7
2 1 3 2
3 1 4 acac
3 1 6 ccaba
8
28
Hint
Sample 1 Explanation
For the first query, appears time and contributes to the value; appears time and contributes ; appears times and contributes . The total value is .
For the second query, appears times and contributes ; appears time and contributes . The total value is .
Constraints
| Test ID | Special Property | ||
|---|---|---|---|
| No operation | |||
| No operations | |||
For of the testdata, , , . At any time, . It is guaranteed that only the three characters will appear.
Translated by ChatGPT 5
京公网安备 11011102002149号