시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2.5 초 | 64 MB | 19 | 3 | 3 | 15.789% |
Professor Zhang would like to solve the multiple pattern matching problem, but he only has only one pattern string $p = p_{1} p_{2} \ldots p_{m}$. So, he wants to generate as many pattern strings as possible from $p$ using the following method:
Now, for a given a string $s = s_{1} s_{2} \ldots s_{n}$, Professor Zhang wants to find all occurrences of all the generated patterns in $s$.
The first line contains two integers $n$ and $m$ ($1 \le n \le 10^5$, $1 \le m \le \min (50\,000, n)$): the lengths of $s$ and $p$, respectively.
The second line contains the string $s$, and the third line contains the string $p$. Both strings consist only of lowercase English letters.
Output a binary string of length $n$. The $i$-th character must be '1' if and only if the substring $s_{i} s_{i+1} \ldots s_{i+m-1}$ is one of the generated patterns. Otherwise, the character must be '0'.
4 1 abac a
1010
4 2 aaaa aa
1110
9 3 abcbacacb abc
100100100