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 Kotlin (1.0.0) (judge verdict: Wrong Answer)

import java.io.*
import java.util.*

val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

fun solve() {
    val (n, m) = nextIntList()
    val s = next()
    var ng = StringBuilder("")
    repeat(m){
        ng.append("1")
    }
    if(s.contains(ng)){
        println(-1)
        return
    }

    var now = n
    val ans:Deque<Int> = ArrayDeque()
    while(now != 0){

        if(now <= m){
            ans.push(now)
            break
        }
        for(i in m downTo 1){
            val next = now - i
            if(s[next] == '0'){
                ans.push(i)
                now = next
                break
            }
        }
    }

    while (ans.isNotEmpty()){
        print("${ans.pop()} ")
    }
    println()
}


fun println(v: String) {
    pw.println(v)
}

fun print(v: String) {
    pw.print(v)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ").toMutableList()
fun nextIntList(index: Int = 0) = next().split(" ").map { it.toInt() + index }.toMutableList()
fun nextLongList(index: Long = 0L) = next().split(" ").map { it.toLong() + index }.toMutableList()
fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toMutableList()

fun ary(n: Int, init: String = "") = Array(n) { init }
fun intAry(n: Int, init: Int = 0) = IntArray(n) { init }
fun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }
fun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }
fun ary2(n: Int, m: Int, init: String = "") = Array(n) { Array(m) { init } }
fun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }
fun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }
fun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }
fun ary3(n: Int, m: Int, k: Int, init: String = "") = Array(n) { Array(m) { Array(k) { init } } }
fun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }
fun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }
fun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }

fun abs(n: Int): Int = Math.abs(n)
fun abs(n: Long): Long = Math.abs(n)
fun abs(n: Double): Double = Math.abs(n)
fun max(a: Int = -INF, b: Int = -INF, c: Int = -INF, d: Int = -INF, e: Int = -INF): Int = listOf(a, b, c, d, e).max()!!
fun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long =
    listOf(a, b, c, d, e).max()!!.toLong()

fun min(a: Int = INF, b: Int = INF, c: Int = INF, d: Int = INF, e: Int = INF): Int = listOf(a, b, c, d, e).min()!!
fun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long =
    listOf(a, b, c, d, e).min()!!.toLong()