Submission #8621091


Source Code Expand

Copy
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::string s;
	std::cin >> s;
	// reverse in the end
	reverse(all(s));
	std::vector<int> safe;
	rep(i,n+1) {
		if(s[i]=='0') safe.emplace_back(i);
	}
	std::vector<int> ans;
	int curr = 0;
	while(curr<n) {
		int l=-1,r=safe.size();
		int next = *(std::upper_bound(safe.begin(),safe.end(),curr+m)-1);
		if(next<=curr) {
			print(-1);
			return 0;
		}
		ans.emplace_back(next-curr);
		curr = next;
	}
	reverse(all(ans));
	for(auto i:ans) {
		std::cout << i << ' ';
	}
	std::cout << ENDL;

	return 0;
}

Submission Info

Submission Time
Task F - Sugoroku
User zln
Language C++14 (GCC 5.4.1)
Score 600
Code Size 1329 Byte
Status AC
Exec Time 19 ms
Memory 2676 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 60
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 AC 6 ms 1528 KB
01-handmade-05 AC 7 ms 1528 KB
01-handmade-06 AC 6 ms 640 KB
01-handmade-07 AC 5 ms 512 KB
01-handmade-08 AC 5 ms 1020 KB
01-handmade-09 AC 19 ms 2676 KB
01-handmade-10 AC 8 ms 2036 KB
02-random-11 AC 5 ms 1528 KB
02-random-12 AC 5 ms 1528 KB
02-random-13 AC 5 ms 1528 KB
02-random-14 AC 5 ms 1528 KB
02-random-15 AC 5 ms 1528 KB
02-random-16 AC 7 ms 1528 KB
02-random-17 AC 5 ms 1528 KB
02-random-18 AC 5 ms 1528 KB
02-random-19 AC 5 ms 1528 KB
02-random-20 AC 5 ms 1528 KB
02-random-21 AC 5 ms 1528 KB
02-random-22 AC 5 ms 1528 KB
02-random-23 AC 5 ms 1528 KB
02-random-24 AC 5 ms 1528 KB
02-random-25 AC 5 ms 1020 KB
02-random-26 AC 5 ms 1528 KB
02-random-27 AC 5 ms 1020 KB
02-random-28 AC 5 ms 1020 KB
02-random-29 AC 5 ms 1020 KB
02-random-30 AC 5 ms 1020 KB
02-random-31 AC 5 ms 1020 KB
02-random-32 AC 5 ms 1020 KB
02-random-33 AC 5 ms 1020 KB
02-random-34 AC 5 ms 1020 KB
02-random-35 AC 5 ms 1020 KB
02-random-36 AC 5 ms 1020 KB
02-random-37 AC 5 ms 1020 KB
02-random-38 AC 5 ms 1020 KB
02-random-39 AC 5 ms 1020 KB
02-random-40 AC 5 ms 1020 KB
02-random-41 AC 5 ms 1020 KB
02-random-42 AC 5 ms 1020 KB
02-random-43 AC 5 ms 1020 KB
02-random-44 AC 5 ms 768 KB
02-random-45 AC 5 ms 768 KB
02-random-46 AC 5 ms 768 KB
02-random-47 AC 5 ms 768 KB
02-random-48 AC 4 ms 768 KB
02-random-49 AC 5 ms 768 KB
02-random-50 AC 4 ms 768 KB
02-random-51 AC 5 ms 768 KB
02-random-52 AC 5 ms 640 KB
02-random-53 AC 4 ms 640 KB
02-random-54 AC 5 ms 640 KB
02-random-55 AC 4 ms 640 KB
02-random-56 AC 4 ms 512 KB
02-random-57 AC 5 ms 512 KB
02-random-58 AC 4 ms 512 KB
02-random-59 AC 4 ms 512 KB