Submission #8627851


Source Code Expand

Copy
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut cur = 0;
    let mut answers = vec![];
    'outer: while cur < n {
        let search_max = min(n + 1, cur + m + 1);
        for i in (cur + 1..search_max).rev() {
            if s[i] == '0' {
                answers.push(i - cur);
                cur = i;
                continue 'outer;
            }
        }
        println!("-1");
        return;
    }
    print_array(&answers);
}

fn print_array<T: std::string::ToString>(array: &Vec<T>) {
    println!(
        "{}",
        array
            .iter()
            .map(|ref x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

Submission Info

Submission Time
Task F - Sugoroku
User ryoryoryo111
Language Rust (1.15.1)
Score 0
Code Size 1450 Byte
Status WA
Exec Time 14 ms
Memory 10620 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 2
WA × 1
AC × 19
WA × 41
Set Name Test Cases
Sample 00-sample-00, 00-sample-01, 00-sample-02
All 00-sample-00, 00-sample-01, 00-sample-02, 01-handmade-03, 01-handmade-04, 01-handmade-05, 01-handmade-06, 01-handmade-07, 01-handmade-08, 01-handmade-09, 01-handmade-10, 02-random-11, 02-random-12, 02-random-13, 02-random-14, 02-random-15, 02-random-16, 02-random-17, 02-random-18, 02-random-19, 02-random-20, 02-random-21, 02-random-22, 02-random-23, 02-random-24, 02-random-25, 02-random-26, 02-random-27, 02-random-28, 02-random-29, 02-random-30, 02-random-31, 02-random-32, 02-random-33, 02-random-34, 02-random-35, 02-random-36, 02-random-37, 02-random-38, 02-random-39, 02-random-40, 02-random-41, 02-random-42, 02-random-43, 02-random-44, 02-random-45, 02-random-46, 02-random-47, 02-random-48, 02-random-49, 02-random-50, 02-random-51, 02-random-52, 02-random-53, 02-random-54, 02-random-55, 02-random-56, 02-random-57, 02-random-58, 02-random-59
Case Name Status Exec Time Memory
00-sample-00 WA 2 ms 4352 KB
00-sample-01 AC 2 ms 4352 KB
00-sample-02 AC 2 ms 4352 KB
01-handmade-03 AC 2 ms 4352 KB
01-handmade-04 WA 2 ms 4352 KB
01-handmade-05 WA 3 ms 4352 KB
01-handmade-06 AC 3 ms 4352 KB
01-handmade-07 AC 2 ms 4352 KB
01-handmade-08 AC 2 ms 4352 KB
01-handmade-09 AC 14 ms 10620 KB
01-handmade-10 AC 2 ms 4352 KB
02-random-11 WA 2 ms 4352 KB
02-random-12 AC 2 ms 4352 KB
02-random-13 WA 2 ms 4352 KB
02-random-14 WA 2 ms 4352 KB
02-random-15 WA 2 ms 4352 KB
02-random-16 WA 4 ms 4352 KB
02-random-17 WA 2 ms 4352 KB
02-random-18 WA 2 ms 4352 KB
02-random-19 WA 2 ms 4352 KB
02-random-20 AC 2 ms 4352 KB
02-random-21 WA 2 ms 4352 KB
02-random-22 WA 2 ms 4352 KB
02-random-23 WA 2 ms 4352 KB
02-random-24 AC 2 ms 4352 KB
02-random-25 WA 2 ms 4352 KB
02-random-26 WA 2 ms 4352 KB
02-random-27 WA 2 ms 4352 KB
02-random-28 AC 2 ms 4352 KB
02-random-29 WA 2 ms 4352 KB
02-random-30 WA 2 ms 4352 KB
02-random-31 WA 2 ms 4352 KB
02-random-32 AC 2 ms 4352 KB
02-random-33 WA 2 ms 4352 KB
02-random-34 WA 2 ms 4352 KB
02-random-35 WA 2 ms 4352 KB
02-random-36 AC 2 ms 4352 KB
02-random-37 WA 2 ms 4352 KB
02-random-38 WA 2 ms 4352 KB
02-random-39 WA 2 ms 4352 KB
02-random-40 AC 2 ms 4352 KB
02-random-41 WA 2 ms 4352 KB
02-random-42 WA 2 ms 4352 KB
02-random-43 WA 2 ms 4352 KB
02-random-44 AC 2 ms 4352 KB
02-random-45 WA 2 ms 4352 KB
02-random-46 WA 2 ms 4352 KB
02-random-47 WA 2 ms 4352 KB
02-random-48 AC 2 ms 4352 KB
02-random-49 WA 2 ms 4352 KB
02-random-50 WA 2 ms 4352 KB
02-random-51 WA 2 ms 4352 KB
02-random-52 AC 2 ms 4352 KB
02-random-53 WA 2 ms 4352 KB
02-random-54 WA 2 ms 4352 KB
02-random-55 WA 2 ms 4352 KB
02-random-56 AC 2 ms 4352 KB
02-random-57 WA 2 ms 4352 KB
02-random-58 WA 2 ms 4352 KB
02-random-59 WA 2 ms 4352 KB