#P3796. AC 自动机(简单版 II)
AC 自动机(简单版 II)
Description
There are pattern strings consisting of lowercase letters and a text string . Each pattern may appear multiple times in the text. You need to find out which pattern strings appear the most times in the text .
Input Format
The input contains multiple test cases. There are at most test cases. The first line of each test case contains a positive integer , indicating the number of pattern strings, where . The next lines each contain a pattern string of length at most . The next line contains a text string of length at most . It is guaranteed that there are no duplicate pattern strings. The input ends with .
Output Format
For each test case, output on the first line the maximum number of occurrences among all pattern strings. Then output several lines, each containing one pattern string that achieves this maximum, in the same order as in the input.
2
aba
bab
ababababac
6
beta
alpha
haha
delta
dede
tata
dedeltalphahahahototatalpha
0
4
aba
2
alpha
haha
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号