time limit per test1 second

            memory limit per test256 megabytes

              inputstandard input

              outputstandard 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.

#include<queue>
#include<stack>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<numeric>//STL数值算法头文件
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<functional>//模板类头文件
using namespace std; const int INF=1e9+7;
const int maxn=201000;
int main()
{
int map[maxn],p[maxn];
int n,a,b,k,sum=0,ans=0;
scanf("%d%d%d%d",&n,&a,&b,&k);
for(int i=1; i<=n; i++)
scanf("%1d",&map[i]);
for(int i=1; i<=n; i++)
{
if(map[i]==0)
{
sum++;
//假设b个点就有一条船
if(sum==b)
{
sum-=b;
p[++ans]=i;
//printf("p[ans]=%d \n",p[ans]);
}
}
else //为1,则一定没有船,从0开始计数
sum=0;
}
//一共a条船,由于只需要打掉一条船,那么只需将可能有船的点打到只剩 (a-1) 就行了 (**ans是每b个数记一次**)
printf("%d\n",ans-(a-1));
for(int i=1; i<=ans-a+1; i++)
printf("%d ",p[i]);
return 0;
}

Sea Battle<海战>(思路题)的更多相关文章

  1. Codeforces 729D Sea Battle(简单思维题)

    http://codeforces.com/contest/738/problem/D https://www.cnblogs.com/flipped/p/6086615.html   原 题意:海战 ...

  2. 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 ...

  3. Codeforces 738D. Sea Battle 模拟

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

  4. Codeforces #380 div2 D(729D) Sea Battle

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

  5. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  6. 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 ...

  7. A. Sea Battle

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

  8. Sea Battle

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

  9. Codeforces Round #380 (Div. 2)D. Sea Battle

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

随机推荐

  1. 2017ACM暑期多校联合训练 - Team 8 1002 HDU 6134 Battlestation Operational (数论 莫比乌斯反演)

    题目链接 Problem Description The Death Star, known officially as the DS-1 Orbital Battle Station, also k ...

  2. Sublime之插件的安装(一)

    由于最近刚换了一个工作,所以决定重新申请一个blog,把工作当中遇到的一些问题记录下来,方便自己下次忘记,也希望能与一起需要的小伙伴一起共勉. 如果有不同的观点或者是不同的看法,大家都可以畅谈,我一直 ...

  3. long类型的数据转化为时间

    long time = 111111111111111111111:SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm: ...

  4. DHCP简单配置

    DHCP是什么? DHCP动态主机地址管理协议(Dynamic Host Configuration Protocol)是一种基于UDP协议且仅限用于局域网内使用的网络协议,最主要的用途是为局域网内部 ...

  5. Java-悲观锁和乐观锁

    Java中的乐观锁与悲观锁: 1. Java中典型的synchronized就是一种悲观锁,也就是独占锁,不过JDK1.6之后对synchronized已经做了许多优化,也不能说是完全的悲观锁了: 2 ...

  6. Linux软件管理器(如何使用软件管理器来管理软件)

    我们的Linux系统大部分都是某个Linux厂商的系统,所以这些厂商可以编译好一些软件来提供用户下载,用户下载完了之后就可以直接安装,从而省去了编译源码及其过程中的各种问题.这时我们就可以使用相应的软 ...

  7. 51Nod 1352 集合计数(扩展欧几里德)

    题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1352 题目大意: 给出N个固定集合{1,N},{2,N-1} ...

  8. ISSCC 2017论文导读 Session 14:A 288μW Programmable Deep-Learning Processor with 270KB On-Chip Weight

    A 288μW Programmable Deep-Learning Processor with 270KB On-Chip Weight Storage Using Non-Uniform Mem ...

  9. hdu 1907(Nim博弈)

    John Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submis ...

  10. C# 6.0 新特性 (三)

    主构造函数 自动属性初始化表达式尤其适合与主构造函数结合使用.主构造函数为降低常见对象模式的繁琐程度提供了一种方法.此功能自五月以来已显著改进.更新包括: 主构造函数的可选实现主体:这将支持此前不受支 ...