#P3808. AC 自动机(简单版)
AC 自动机(简单版)
Description
Given pattern strings and a text string , count how many distinct pattern strings appear in the text. Two pattern strings are different if and only if their indices are different.
Input Format
The first line contains an integer , the number of pattern strings.
Lines to each contain one string; the string on line is the pattern string with index .
The last line contains a string, the text string .
Output Format
Output a single integer on one line, which is the answer.
3
a
aa
aa
aaa
3
4
a
ab
ac
abc
abcd
3
2
a
aa
aa
2
Hint
Sample 1 Explanation
and have different indices, so each contributes once to the answer.
Sample 2 Explanation
, , and all appear in the string abcd.
Constraints
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that , , . contain only lowercase letters.
Translated by ChatGPT 5
京公网安备 11011102002149号