AcWing 4616. 击中战舰
原题链接
中等
作者:
代码人生
,
2022-09-23 09:38:24
,
所有人可见
,
阅读 170
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
const int N = 2e5 + 10;
char s[N];
int n,a,b,k;
int main(){
scanf("%d %d %d %d",&n,&a,&b,&k);
scanf("%s",s + 1);
vector<int> ans;
int cnt = 0;
for(int i=1;i<=n;i++){
if(s[i] == '0'){
cnt++;
if(cnt == b){
cnt = 0;
ans.push_back(i);
}
}
else cnt = 0;
}
cout << ans.size() - a + 1 << endl;
for(int i=0;i<ans.size() - a + 1;i++){
cout << ans[i] << " ";
}
return 0;
}