#SRD0000112. Chiếc váy cưới của Fabby (Fabby and Her Wedding Dress)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Chiếc váy cưới của Fabby (Fabby and Her Wedding Dress)
Fabby and Her Wedding Dress
Source: Toph
Version: Phuoc Hung OJ Extended
Problem Statement
Fabby has a list of strings , consisting only of lowercase English letters.
For a nonempty pattern string , define its beauty as the number of indices for which is a prefix of . Equivalently, and the first characters of are exactly . Equal strings at different indices are counted separately.
Process operations in their given order:
1 i j C: replace the -th character of with the lowercase letterC. String length does not change.2 T: print the beauty of pattern in the list after all earlier updates.
Output the answer to every operation of the second type.
Input
- The first line contains the integer .
- The next lines contain .
- The next line contains .
- The final lines contain operations of the form
1 i j Cor2 T.
All indices are 1-based, and strings contain no whitespace.
Output
For each operation 2 T, print the number of strings having as a prefix, one integer per line.
Subtasks
-
Subtask 1 (15 points): , , , , and the total length of all query patterns is at most ; , , and every character is a lowercase English letter.
-
Subtask 2 (15 points): , , , and total query-pattern length is at most ; indices and alphabet as in Subtask 1.
-
Subtask 3 (30 points): , , , and total query-pattern length is at most ; indices and alphabet as in Subtask 1.
-
Subtask 4 (40 points): , , , and total query-pattern length is at most ; indices and alphabet as in Subtask 1.
Examples
Example 1
Input
2
abcd
abde
2
1 2 3 c
2 abc
Output
2
Explanation
After the update both strings are abcd, so both start with abc; the result is .