P28322 [洛谷] AC Automaton (Simple Version)
提高
题目描述

Problem Description

Given $n$ pattern strings $s_i$ and a text string $t$, determine how many different pattern strings have appeared in the text string. Two pattern strings are considered different if and only if their indices are different.

Input Format

The first line contains an integer representing the number of pattern strings, $n$.
From the second line to the $(n + 1)$-th line, each line contains a string, where the $(i + 1)$-th line's string represents the pattern string $s_i$ with index $i$.
The last line contains a string representing the text string $t$.

Output Format

Output a single integer representing the answer.

Sample Input and Output

Input Sample #1

3
a
aa
aa
aaa

Output Sample #1

3

Input Sample #2

4
a
ab
ac
abc
abcd

Output Sample #2

3

Input Sample #3

2
a
aa
aa

Output Sample #3

2

Notes/Hints

Sample 1 Explanation

$s_2$ and $s_3$ have different indices (positions), thus each contributes once to the answer.

Sample 2 Explanation

$s_1$, $s_2$, and $s_4$ all appear in the string abcd.

Data Size and Constraints

  • For $50\%$ of the test cases, $n = 1$.
  • For $100\%$ of the test cases, $1 \leq n \leq 10^6$, $1 \leq |t| \leq 10^6$, $1 \leq \sum_{i = 1}^n |s_i| \leq 10^6$. $s_i$ and $t$ contain only lowercase letters.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 a aa aa aaa
样例输出
3