#5996. [CERC 2022] Insertions
[CERC 2022] Insertions
[CERC 2022] Insertions
题目描述
We are given three strings, $s$, $t$ and $p$. We will denote the length of a string by vertical bars, thus $|s|$ is the length of $s$ and so on. If we insert $t$ into $s$ at position $k$, where $0 \leq k \leq |s|$, the result is a new string consisting of the first $k$ characters of $s$, followed by the entirety of $t$, and finally followed by the remaining $|s| - k$ characters of $s$. We would like to select $k$ so that the resulting new string will contain the largest possible number of occurrences of $p$ as a substring.Thus, for example, inserting into at position results in the string ; at , in the string ; and at , in the string . If we are interested in occurrences of , then the best position to insert into is , where we get two occurrences: and (as this example shows, occurrences of are allowed to overlap). If, on the other hand, we were interested in occurrences of , then the best choices of would be and , which result in one occurrence of , whereas results in 0 occurrences of .
输入格式
The first line contains the string $s$, the second line the string $t$, and the third line the string $p$.输出格式
Output one line containing the following four integers, separated by spaces:- The maximum number of occurrences of we can get after inserting into at position , if we choose the position wisely.
- The number of different 's (from the range ) where this maximum number of occurrences of is attained.
- The minimum value of where the maximum number of occurrences of is attained.
- The maximum value of where the maximum number of occurrences of is attained.
ab
aba
aba
2 1 2 2
abaab
aba
ababa
1 3 1 5
eeoeo
eoe
eeo
2 3 1 4
提示
### CommentThe first of these three examples is the one discussed earlier in the problem statement
Input limits
- All the strings consist only of lowercase letters of the English alphabet. 标签: P13812|树状数组|2022|KMP 算法|ICPC|CERC