#P6080. [USACO05DEC] Cow Patterns G

[USACO05DEC] Cow Patterns G

Description

Among Farmer John’s NN cows (1N1051 \leq N \leq 10^5), there are KK troublemakers (1K250001 \leq K \leq 25000)! These troublemakers always stand together when the cows line up. Now you need to help FJ find them.

To tell cows apart, FJ gave each cow a tag with a number between 1S1 \ldots S (1S251 \leq S \leq 25). Although this is not a perfect method, it still helps. Now FJ cannot remember the exact numbers of the troublemakers, but he provides a pattern sequence. If some troublemakers had the same number in the original group, then the corresponding numbers in the pattern sequence are still the same. Also, the relative ordering of the numbers in the pattern sequence is the same as in the original group.

For example, for the pattern sequence: 1,4,4,3,2,11,4,4,3,2,1, in the original group of 66 troublemakers, the first and last numbers are equal and are the smallest (not necessarily 11), and the troublemakers at positions 2,32,3 have the same number and are the largest (not necessarily 44).

Now consider this lineup: 5,6,2,10,10,7,3,2,95, 6, 2, 10, 10, 7, 3, 2, 9. Its substring 2,10,10,7,3,22, 10, 10, 7, 3, 2 matches the equality relationships and size relationships of the pattern sequence, so it could be a troublemaker group.

Find all possible locations of such groups.

Input Format

The first line contains three integers N,K,SN, K, S.

The next NN lines each contain one integer, representing the tag number of the ii-th cow.

The next KK lines each contain one integer, representing the number at position ii in the pattern sequence.

Output Format

The first line outputs an integer BB.

The next BB lines each contain one integer, the starting position of one possible troublemaker group.

Output all positions in increasing order.

9 6 10
5
6
2
10
10
7
3
2
9
1
4
4
3
2
1
1
3

Hint

Translated by ChatGPT 5