#P10634. BZOJ2372 music
BZOJ2372 music
Problem Description
A war has recently broken out between countries A and B. dick, as the commander-in-chief of country A, has been having a headache about intelligence. This is because country B has recently hired a cryptography expert named Easy to encrypt all of their communications.
Easy likes singing very much, so he decided to store all signals as melodies. For example, could be a sequence of encrypted notes. We represent it with a sequence of the same length, which becomes . To increase confidentiality, he further adjusted the encrypted score by changing some pitches, turning the original sequence into , where , and for we have , for we have , and for we have . For example, 11221 and 55775 may represent the same melody.
Recently, dick intercepted a signal that may contain important information. Based on past experience, dick already knows what some melodies mean. So dick wants to know: for a known melody, can we determine whether it appears in the intercepted melody? If it does, can we find how many times it appears and at which positions?
"Task": Determine the number of occurrences and the positions where the given melody appears in the intercepted melody.
Input Format
The first line contains three positive integers . is the length of the intercepted melody, is the length of the known melody. All melodies are positive integers in .
The next lines each contain one integer describing the intercepted melody .
The next lines each contain one integer describing the known melody .
Output Format
The first line contains an integer , the number of occurrences.
Then output lines. In increasing order, give the starting position of each occurrence, i.e. is equivalent to .
9 6 10
5
6
2
10
10
7
3
2
9
1
4
4
3
2
1
1
3
Hint
For all testdata, it is guaranteed that , 。
Translated by ChatGPT 5