Hi Guys , I Just Tried to solve the Sea Battle problem , hope you might like it , please share if you’ve any better code .
#include<stdio.h>
#include<stdlib.h>
typedef unsigned u;
char S[222222];u Q[222222],Qi;
int main()
{
u n,a,b,i,j,k;
scanf(“%u%u%u%u%s”,&n,&a,&b,&k,S);
for(i=-1,j=0;++i<n;) { //printf(“!%u \’%c\’ %u\n”,i,S[i],j); if(S[i]==’1′)j=0; else if(++j==b) {Q[Qi++]=i;j=0;} //printf(“>%u \’%c\’ %u\n”,i,S[i],j);
}
printf(“%u\n”,Qi-(–a));
for(i=a-1;++i<Qi;)printf(“%u%c”,Q[i]+1,i+1!=Qi?’ ‘:’\n’);
return 0;
}