#P4173. 残缺的字符串
残缺的字符串
Description
Long ago, when you had just learned string matching, there were two strings and containing only lowercase letters, with lengths and respectively. Now, when you encounter these two strings again, they have aged; each string has become partially damaged.
You want to match the two strings again, taking as the pattern. For every position in , determine whether the length- substring starting at this position could exactly match string .
Input Format
The first line contains two positive integers , representing the lengths of strings and respectively.
The second line contains a string of length .
The third line contains a string of length .
Both strings consist only of lowercase letters and , where indicates that the corresponding position is damaged and each can match any single lowercase letter.
Output Format
The first line contains an integer , the number of starting positions in where can exactly match.
If , then on the second line output positive integers in increasing order, each being a valid starting position (indices start from ).
3 7
a*b
aebr*ob
2
1 5
Hint
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号