ZeptoLab Code Rush 2015
D
Om Nom and Necklace
Codeforces
2200
原题
← CE →
翻译中…

One day Om Nom found a thread with $*n*$ beads of different colors. He decided to cut the first several beads from this thread to make a bead necklace and present it to his girlfriend Om Nelly.

翻译中…

image

翻译中…

Om Nom knows that his girlfriend loves beautiful patterns. That's why he wants the beads on the necklace to form a regular pattern. A sequence of beads $*S*$ is regular if it can be represented as $*S* = *A* + *B* + *A* + *B* + *A* + ... + *A* + *B* + *A*$, where $*A*$ and $*B*$ are some bead sequences, "$+$" is the concatenation of sequences, there are exactly $2*k* + 1$ summands in this sum, among which there are $*k* + 1$ "$*A*$" summands and $*k*$ "$*B*$" summands that follow in alternating order. Om Nelly knows that her friend is an eager mathematician, so she doesn't mind if $*A*$ or $*B*$ is an empty sequence.

翻译中…

Help Om Nom determine in which ways he can cut off the first several beads from the found thread (at least one; probably, all) so that they form a regular pattern. When Om Nom cuts off the beads, he doesn't change their order.

翻译中…

Input

翻译中…

The first line contains two integers $*n*$, $*k*$ ($1 ≤ *n*, *k* ≤ 1 000 000$) — the number of beads on the thread that Om Nom found and number $*k*$ from the definition of the regular sequence above.

翻译中…

The second line contains the sequence of $*n*$ lowercase Latin letters that represent the colors of the beads. Each color corresponds to a single letter.

翻译中…

Output

翻译中…

Print a string consisting of $*n*$ zeroes and ones. Position $*i*$ ($1 ≤ *i* ≤ *n*$) must contain either number one if the first $*i*$ beads on the thread form a regular sequence, or a zero otherwise.

翻译中…

Note

翻译中…

In the first sample test a regular sequence is both a sequence of the first 6 beads (we can take $*A* =$"", $*B* =$"bca"), and a sequence of the first 7 beads (we can take $*A* =$"b", $*B* =$"ca").

翻译中…

In the second sample test, for example, a sequence of the first 13 beads is regular, if we take $*A* =$"aba", $*B* =$"ba".

翻译中…

样例

Input #1
7 2
bcabcab
Output #1
0000011
InputCopy OutputCopy
Input #2
21 2
ababaababaababaababaa
Output #2
000110000111111000011
InputCopy OutputCopy
题目信息
题号
526D
时间限制
1 s
内存限制
256 MB
标签
哈希
后缀结构
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。