CF526D.Om Nom and Necklace

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

One day Om Nom found a thread with nn 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.

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 SS is regular if it can be represented as S=A+B+A+B+A+...+A+B+AS=A+B+A+B+A+...+A+B+A , where AA and BB are some bead sequences, " ++ " is the concatenation of sequences, there are exactly 2k+12k+1 summands in this sum, among which there are k+1k+1 " AA " summands and kk " BB " summands that follow in alternating order. Om Nelly knows that her friend is an eager mathematician, so she doesn't mind if AA or BB 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.

输入格式

The first line contains two integers nn , kk ( 1<=n,k<=10000001<=n,k<=1000000 ) — the number of beads on the thread that Om Nom found and number kk from the definition of the regular sequence above.

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

输出格式

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

输入输出样例

  • 输入#1

    7 2
    bcabcab
    

    输出#1

    0000011
  • 输入#2

    21 2
    ababaababaababaababaa
    

    输出#2

    000110000111111000011

说明/提示

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

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

首页