#P3796. Maximal Occurrence Patterns
Maximal Occurrence Patterns
Maximal Occurrence Patterns
You are given \(N\) patterns consisting of lowercase letters and a text string \(T\). Each pattern may occur multiple times in \(T\) (possibly overlapping). Your task is to find out which patterns appear in \(T\) the maximum number of times.
In other words, for each pattern \(P_i\), count the number of times it appears in \(T\) (allowing overlapping occurrences). Then, output all the patterns that have the highest frequency of occurrence. The order of the output should be the same as the input order.
Note: The occurrence count should consider overlapping matches. For example, if \(T = \texttt{aaa}\) and the pattern is \(\texttt{aa}\), it occurs twice (at positions 0 and 1).
inputFormat
The first line contains an integer \(N\) indicating the number of patterns. Each of the next \(N\) lines contains a non-empty pattern string (only lowercase letters). The last line contains the text string \(T\) which consists of lowercase letters.
\(1 \leq N \leq 100\). The length of each pattern and string \(T\) is at most 104.
outputFormat
Output each pattern (one per line) that appears the maximum number of times in \(T\). The patterns should be output in the same order as they appear in the input.
sample
3
ab
bc
abc
abcabc
ab
bc
abc
</p>