Problem:
Score : 600 points

Problem Statement

Takahashi is playing a board game called Sugoroku.

On the board, there are N + 1 squares numbered 0 to N. Takahashi starts at Square 0, and he has to stop exactly at Square N to win the game.

The game uses a roulette with the M numbers from 1 to M. In each turn, Takahashi spins the roulette. If the number x comes up when he is at Square s, he moves to Square s+x. If this makes him go beyond Square N, he loses the game.

Additionally, some of the squares are Game Over Squares. He also loses the game if he stops at one of those squares. You are given a string S of length N + 1, representing which squares are Game Over Squares. For each i (0 \leq i \leq N), Square i is a Game Over Square if S[i] = 1 and not if S[i] = 0.

Find the sequence of numbers coming up in the roulette in which Takahashi can win the game in the fewest number of turns possible. If there are multiple such sequences, find the lexicographically smallest such sequence. If Takahashi cannot win the game, print -1.

Constraints

1 \leq N \leq 10^5

1 \leq M \leq 10^5

|S| = N + 1

S consists of 0 and 1.

S[0] = 0

S[N] = 0

Input

Input is given from Standard Input in the following format:

N M
S

Output

If Takahashi can win the game, print the lexicographically smallest sequence among the shortest sequences of numbers coming up in the roulette in which Takahashi can win the game, with spaces in between.

If Takahashi cannot win the game, print -1.

Sample Input 1

9 3
0001000100

Sample Output 1

1 3 2 3

If the numbers 1, 3, 2, 3 come up in this order, Takahashi can reach Square 9 via Square 1, 4, and 6. He cannot reach Square 9 in three or fewer turns, and this is the lexicographically smallest sequence in which he reaches Square 9 in four turns.

Sample Input 2

5 4
011110

Sample Output 2

-1

Takahashi cannot reach Square 5.

Sample Input 3

6 6
0101010

Sample Output 3

6

Solution in C# (Mono 4.6.2.0) (judge verdict: Time Limit Exceeded)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var NM = ReadLine().Split().Select(int.Parse).ToArray();
        var N = NM[0];
        var M = NM[1];
        var map = new bool[N + 1];
        var s = ReadLine();
        var m = 0;
        var count = 0;
        for (int i = 0; i < N + 1; i++)
        {
            if (s[i] == '1')
            {
                count++;
            }
            else
            {
                m = Max(m, count);
                count = 0;
            }
            map[i] = s[i] == '0';
        }

        Array.Reverse(map);

        var lis = new List<int>();
        var sp = new SparseTable<bool>(map,(x,y)=>x&y);
        var k=0;
        while (k!=map.Length-1)
        {

            var ok =k;
            var ng=k+M;
            if(ng>N)ng=N;
            var aaa=ng;
            if(map[ng]){
                lis.Add(M);
            }
            else{
            while (ng-ok>1)
            {
                var mid =(ok+ng)/2;
                if(sp.Query(k,mid)){
                    ok=mid;
                }
                else
                {
                    ng=mid;
                }
            }
            lis.Add(ng);
            lis.Add(aaa);
            }
        }
        var aaaa= lis.ToArray();
        Array.Reverse(aaaa);
         
         WriteLine(string.Join(" ",aaaa ));

    }

    static void C()
    {
        var ABX = ReadLine().Split().Select(long.Parse).ToArray();
        var A = ABX[0];
        var B = ABX[1];
        var X = ABX[2];
        var x = X;
        var c = 0;
        while (x != 0)
        {
            c++;
            x /= 10;
        }
        var ans = 0L;
        for (int i = 0; i <= c; i++)
        {
            var n = (X - B * i) / A;
            ans = Max(ans, n);
        }
        WriteLine(ans);
    }
}

public class SparseTable<T> // where (T, F<T, T, T>): 冪等半群 
{
    T[][] buffer; // 2次元配列よりQueryもctorも速いのウケ
    Func<T, T, T> F;
    int[] log2; // floor(log2(n))

    public SparseTable(T[] init, Func<T, T, T> f)
    {
        F = f;

        var n = init.Length;

        log2 = new int[n + 1];
        log2[0] = -1;
        for (int i = 2; i < log2.Length; i++)
        {
            log2[i] = log2[i >> 1] + 1;
        }

        buffer = new T[log2[n] + 1][];
        for (int i = 0; i < buffer.Length; i++)
        {
            buffer[i] = new T[n - (1 << i) + 1];
        }

        Array.Copy(init, 0, buffer[0], 0, init.Length);
        for (int i = 1, p = 1; i < buffer.Length; i++, p <<= 1)
        {
            for (int j = 0; j < buffer[i].Length; j++)
            {
                buffer[i][j] = F(buffer[i - 1][j], buffer[i - 1][j + p]);
            }
        }
    }

    public T Query(int l, int r)//l < r   
    {
        var h = log2[r - l];
        return F(buffer[h][l], buffer[h][r - (1 << h)]);
    }
}