Submission #8619258


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int n;
pair<int,int> seg[maxn], ans[maxn];
void upd(int p, int v){
	for(seg[p += n] = {v, p}; p > 1; p >>= 1)
		seg[p>>1] = min(seg[p], seg[p ^ 1]);
}
pair<int,int> qry(int l, int r){
	pair<int,int> ans = {1<<30, 1<<30};
	for(l += n, r += n; l < r; l >>= 1, r >>= 1){
		if(l&1) ans = min(ans, seg[l++]);
		if(r&1) ans = min(ans, seg[--r]);
	}
	return ans;
}
int main(){
	int m; cin >> n >> m;
	string s; cin >> s;
	n++;
	upd(n - 1, 0);
	for(int i = n - 2; i >= 0; i--){
		pair<int,int> b = {1<<30, 1<<30};
		if(s[i] == '0'){
			b = qry(i + 1, min(i + m + 1, n));
		}
		b.first++;
		upd(i, b.first);
		ans[i] = b;
	}
	if(ans[0].first >= (1<<30)) cout << -1 << endl;
	else {
		int p = 0;
		while(p != n - 1){
			cout << ans[p].second - p << " ";
			p = ans[p].second;
		}
		cout << endl;
	}
	return 0;
}

Submission Info

Submission Time
Task F - Sugoroku
User FMota
Language C++14 (GCC 5.4.1)
Score 0
Code Size 915 Byte
Status RE
Exec Time 109 ms
Memory 768 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 3
AC × 4
RE × 56
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 AC 1 ms 256 KB
00-sample-01 AC 1 ms 256 KB
00-sample-02 AC 1 ms 256 KB
01-handmade-03 AC 1 ms 256 KB
01-handmade-04 RE 105 ms 512 KB
01-handmade-05 RE 101 ms 512 KB
01-handmade-06 RE 106 ms 512 KB
01-handmade-07 RE 105 ms 512 KB
01-handmade-08 RE 105 ms 512 KB
01-handmade-09 RE 105 ms 512 KB
01-handmade-10 RE 104 ms 512 KB
02-random-11 RE 101 ms 512 KB
02-random-12 RE 103 ms 512 KB
02-random-13 RE 104 ms 512 KB
02-random-14 RE 105 ms 512 KB
02-random-15 RE 107 ms 384 KB
02-random-16 RE 103 ms 768 KB
02-random-17 RE 101 ms 512 KB
02-random-18 RE 102 ms 512 KB
02-random-19 RE 104 ms 512 KB
02-random-20 RE 104 ms 512 KB
02-random-21 RE 105 ms 512 KB
02-random-22 RE 105 ms 512 KB
02-random-23 RE 106 ms 512 KB
02-random-24 RE 102 ms 512 KB
02-random-25 RE 106 ms 512 KB
02-random-26 RE 106 ms 512 KB
02-random-27 RE 109 ms 384 KB
02-random-28 RE 105 ms 384 KB
02-random-29 RE 103 ms 384 KB
02-random-30 RE 105 ms 512 KB
02-random-31 RE 105 ms 512 KB
02-random-32 RE 105 ms 512 KB
02-random-33 RE 101 ms 512 KB
02-random-34 RE 101 ms 512 KB
02-random-35 RE 103 ms 512 KB
02-random-36 RE 105 ms 512 KB
02-random-37 RE 102 ms 384 KB
02-random-38 RE 101 ms 512 KB
02-random-39 RE 102 ms 512 KB
02-random-40 RE 101 ms 512 KB
02-random-41 RE 100 ms 512 KB
02-random-42 RE 100 ms 512 KB
02-random-43 RE 101 ms 512 KB
02-random-44 RE 101 ms 512 KB
02-random-45 RE 103 ms 512 KB
02-random-46 RE 102 ms 512 KB
02-random-47 RE 102 ms 512 KB
02-random-48 RE 103 ms 384 KB
02-random-49 RE 103 ms 512 KB
02-random-50 RE 101 ms 512 KB
02-random-51 RE 102 ms 512 KB
02-random-52 RE 103 ms 512 KB
02-random-53 RE 107 ms 512 KB
02-random-54 RE 101 ms 512 KB
02-random-55 RE 101 ms 512 KB
02-random-56 RE 101 ms 512 KB
02-random-57 RE 101 ms 512 KB
02-random-58 RE 100 ms 512 KB
02-random-59 RE 101 ms 512 KB