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 bconsecutive 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 nabk (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.

把可能是船的位置都标出来

 //2017-08-01
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm> using namespace std; const int N = ;
char arr[N];
int n, a, b, k;
int shot[N]; int main(){
while(scanf("%d%d%d%d", &n, &a, &b, &k)!=EOF){
scanf("%s", arr);
int num = , tmp = ;
for(int i = ; i < n; i++){
if(arr[i] == '')tmp++;
else tmp = ;
if(tmp == b){
tmp = ;
shot[num++] = i+;
}
}
printf("%d\n", num-a+);
for(int i = ; i < num-a+; i++)
printf("%d ", shot[i]);
printf("\n");
} return ;
}

Codeforces729D(SummerTrainingDay01-F)的更多相关文章

  1. Mysql_以案例为基准之查询

    查询数据操作

  2. 在 C# 里使用 F# 的 option 变量

    在使用 C# 与 F# 混合编程的时候(通常是使用 C# 实现 GUI,F#负责数据处理),经常会遇到要判断一个 option 是 None 还是 Some.虽然 Option module 里有 i ...

  3. 如果你也会C#,那不妨了解下F#(7):面向对象编程之继承、接口和泛型

    前言 面向对象三大基本特性:封装.继承.多态.上一篇中介绍了类的定义,下面就了解下F#中继承和多态的使用吧.

  4. 如果你也会C#,那不妨了解下F#(2):数值运算和流程控制语法

    本文链接:http://www.cnblogs.com/hjklin/p/fs-for-cs-dev-2.html 一些废话 一门语言火不火,与语言本身并没太大关系,主要看语言的推广. 推广得好,用的 ...

  5. 使用F#开发ASP.NET Core应用程序

    .NET Core 里的F# 在.NET Core刚发布时,就已经添加了对F#的支持.但因为当时F#组件还不完整,而一些依赖包并没有放在Nuget上,而是社区自己放到MyGet上,所以在使用dotne ...

  6. 如果你也会C#,那不妨了解下F#(6):面向对象编程之“类”

    前言 面向对象的思想已经非常成熟,而使用C#的程序员对面向对象也是非常熟悉,所以我就不对面向对象进行介绍了,在这篇文章中将只会介绍面向对象在F#中的使用. F#是支持面向对象的函数式编程语言,所以你用 ...

  7. 如果你也会C#,那不妨了解下F#(5):模块、与C#互相调用

    F# 项目 在之前的几篇文章介绍的代码都在交互窗口(fsi.exe)里运行,但平常开发的软件程序可能含有大类类型和函数定义,代码不可能都在一个文件里.下面我们来看VS里提供的F#项目模板. F#项目模 ...

  8. 如果你也会C#,那不妨了解下F#(4):了解函数及常用函数

    函数式编程其实就是按照数学上的函数运算思想来实现计算机上的运算.虽然我们不需要深入了解数学函数的知识,但应该清楚函数式编程的基础是来自于数学. 例如数学函数\(f(x) = x^2+x\),并没有指定 ...

  9. 如果你也会C#,那不妨了解下F#(3):F#集合类型和其他核心类型

    本文链接:http://www.cnblogs.com/hjklin/p/fs-for-cs-dev-3.html 在第一篇中,我们介绍了一些基础数据类型,其实那篇标题中不应该含有"F#&q ...

  10. 如果你也会C#,那不妨了解下F#(1):F# 数据类型

    本文链接:http://www.cnblogs.com/hjklin/p/fs-for-cs-dev-1.html 简单介绍 F#(与C#一样,念作"F Sharp")是一种基于. ...

随机推荐

  1. 10_python_函数进阶

    一.函数参数-动态参数 形参:位置参数.默认值参数.动态参数 动态参数分为两种:动态接收位置参数 *args  .动态接收关键字参数 *kwargs     1. *args def chi(*foo ...

  2. cad2018卸载/安装失败/如何彻底卸载清除干净cad2018注册表和文件的方法

    cad2018提示安装未完成,某些产品无法安装该怎样解决呢?一些朋友在win7或者win10系统下安装cad2018失败提示cad2018安装未完成,某些产品无法安装,也有时候想重新安装cad2018 ...

  3. 学习使用Apollo配置中心

    Apollo(阿波罗)是携程框架部门研发的配置管理平台,能够集中化管理应用不同环境.不同集群的配置,配置修改后能够实时推送到应用端. Apollo官网地址 如何安装服务端可以按照上面官网的步骤. 这里 ...

  4. 微信赌场——H5棋牌游戏渗透之旅

    i春秋作家:F0rmat 0x01 前言 本来不想发的,涉及太多利益了,这些棋牌游戏的源码最高能卖到几万.开发起来不比一个商场程序难.最近又太忙了,没时间去做代码审计的文章了,但一不小心又抢了个运气王 ...

  5. Vue2.5开发去哪儿网App 搜索功能完成

    效果展示: Search.vue: <div class="search-content" ref="search" v-show="keywo ...

  6. centos7.2 部署zabbix 3.2.7

    centos7.2 部署zabbix 3.2.7[zabbix@zabbixServer ~]$ cat /etc/redhat-release CentOS Linux release 7.2.15 ...

  7. MVC3学习:利用jquery+ajax生成二维码(支持中文)

    二维码越来越热火了,做电子商务网站,不做二维码,你就OUT了. 一.下载DLL文件(ThoughtWorks.QRCode.dll),并在项目中引用.点此下载 如果你还不知道什么是QRCode二维码, ...

  8. c++之window.h

    在c++中引入window.h头文件. Sleep函数,此函数接受一个时间参数,单位是ms.即使得程序在一段时间后继续运行.如下: 在hello输出之后3000ms,才会继续输出world字符串. M ...

  9. editplus tag

    #T=HTML<!DOCTYPE html><html lang="zh-CN"><head><meta content="te ...

  10. sql的存储过程实例--循环动态创建表

    创建一个存储过程,动态添加100张track表表名track_0 ~~ track_99注:sql的拼接只能用 CONCAT()函数 -- 创建一个存储过程 CREATE PROCEDURE crea ...