D. Sea Battle
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.

Galya doesn't know the ships location. She can shoot to some cells and after each shot she is told if that cell was a part of some ship (this case is called "hit") or not (this case is called "miss").

Galya has already made k shots, all of them were misses.

Your task is to calculate the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship.

It is guaranteed that there is at least one valid ships placement.

Input

The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made.

The second line contains a string of length n, consisting of zeros and ones. If the i-th character is one, Galya has already made a shot to this cell. Otherwise, she hasn't. It is guaranteed that there are exactly k ones in this string.

Output

In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship.

In the second line print the cells Galya should shoot at.

Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from the left.

If there are multiple answers, you can print any of them.

Examples
Input
5 1 2 1
00100
Output
2
4 2
Input
13 3 2 3
1000000010001
Output
2
7 11
Note

There is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.

/*
RE返回T我也是醉了.......
*/
/*
贪心先看海面上能撑下几艘船。然后只要打sum-a+1个点就能保证至少能达到一艘船
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
//freopen("C:\\Users\\acer\\Desktop\\in.txt","r",stdin);
int n,a,b,k;
char op[];
scanf("%d%d%d%d",&n,&a,&b,&k);
scanf("%s",op+);
//cout<<op<<endl;
vector<int>v;
int l=;
for(int i=;i<=n;i++){
//cout<<op[i];
if(op[i]==''){
l=i;
}
if(i-l==b){
v.push_back(i);
l=i;
}
}
//cout<<endl;
printf("%d\n",v.size()-a+);
for(int i=;i<v.size()-a+;i++)
printf(i?" %d":"%d",v[i]);
return ;
}

Codeforces Round #380 (Div. 2)D. Sea Battle的更多相关文章

  1. Codeforces Round #433 (Div. 2)【A、B、C、D题】

    题目链接:Codeforces Round #433 (Div. 2) codeforces 854 A. Fraction[水] 题意:已知分子与分母的和,求分子小于分母的 最大的最简分数. #in ...

  2. Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2) D. Sea Battle 模拟

    D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  3. Codeforces Round #380 (Div. 2)/729D Sea Battle 思维题

    Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the ...

  4. Codeforces Round #380 (Div. 2) 解题报告

    第一次全程参加的CF比赛(虽然过了D题之后就开始干别的去了),人生第一次codeforces上分--(或许之前的比赛如果都参加全程也不会那么惨吧),终于回到了specialist的行列,感动~.虽然最 ...

  5. Codeforces Round #292 (Div. 1)A. Drazil and Factorial 构造

    A. Drazil and Factorial 题目连接: http://codeforces.com/contest/516/problem/A Description Drazil is play ...

  6. B. Ohana Cleans Up(Codeforces Round #309 (Div. 2))

    B. Ohana Cleans Up   Ohana Matsumae is trying to clean a room, which is divided up into an n by n gr ...

  7. B. The Number of Products(Codeforces Round #585 (Div. 2))

    本题地址: https://codeforces.com/contest/1215/problem/B 本场比赛A题题解:https://www.cnblogs.com/liyexin/p/11535 ...

  8. Codeforces Round #517 (Div. 2)(1~n的分配)

    题:https://codeforces.com/contest/1072/problem/C 思路:首先找到最大的x,使得x*(x+1)/2 <= a+b 那么一定存在一种分割使得 a1 &l ...

  9. Codeforces Round #805 (Div. 3)E.Split Into Two Sets

    题目链接:https://codeforces.ml/contest/1702/problem/E 题目大意: 每张牌上面有两个数字,现在有n张牌(n为偶数),问能否将这n张牌分成两堆,使得每堆牌中的 ...

随机推荐

  1. python基础之五大标准数据类型

    学习一门语言,往往都是从Hello World开始. 但是笔者认为,在一个黑框框中输出一个"你好,世界"并没有什么了不起,要看透事物的本质,熟悉一门语言,就要了解其底层,就是我们常 ...

  2. js两个叹号的使用

    1.浏览器判断空和未定义以及零时返回的值如下: alert(undefined)  //undefined alert(null)  //null alert(0)  //0 2.有时为了便于下一步判 ...

  3. java 多态(动态绑定)

    一.面向对象最核心的机制--动态绑定,也叫多态 1.1.通过下面的例子理解动态绑定,即多态 1 package javastudy.summary; 2 3 class Animal { 4 /** ...

  4. [js高手之路] html5 canvas系列教程 - 像素操作(反色,黑白,亮度,复古,蒙版,透明)

    接着上文[js高手之路] html5 canvas系列教程 - 状态详解(save与restore),相信大家都应该玩过美颜功能,而我们今天要讲的就是canvas强大的像素处理能力,通过像素处理,实现 ...

  5. 再起航,我的学习笔记之JavaScript设计模式27(链模式)

    链模式 概念介绍 链模式(Operatc of Responsibility): 通过在对象方法中将当前对象返回,实现对同一个对象多个方法的链式调用.从而简化对该对象的多个方法的多次调用时,对该对象的 ...

  6. shim 和 polyfill

    在前端,有两个词经常被提及:shim 和 polyfill.最近在翻译文章时又遇到了 polyfill 这个词,准备把这两个概念理清楚. 关于 JavaScript 的兼容性问题,通常有不同的解决方案 ...

  7. SQLserver2008r2安装过程

    首先,下载SQLserver2008的安装包,下载完成打开是以下界面 点击开始安装,随着安装进程,点下一步 . 接着来到设置角色的过程,点击SQL功能安装 然后按下一步,来到功能选择,点击" ...

  8. Elixir游戏服设计六

    接上章,我新建了个app做包含Table模型, TableServer等.Table桌子的代码暂时如下, 有一些状态还没用上 defmodule Table do @state_accept 0 #准 ...

  9. 数据库中删除语句Drop、Delete、Truncate的相同点和不同点的比较

    数据库删除语句的分别介绍: Delete:用于删除表中的行(注:可以删除某一行:也可以在不删除表的情况下(即意味着表的结构.属性.索引完整)删除所有行) 语法:删除某一行:Delete From 表名 ...

  10. Linux基本符号

    Linux环境下一些常用的符号 ; 多个命令的分隔符 / 根目录或路径分隔符 > 重定向,数据沿箭头方向流动,原来文件内容会被丢弃 >> 追加重定向,在原来文件结尾追加内容 .. 上 ...