Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

int main() 
    fastio();

    int n,k,c;
    string s;
    cin>>n>>k>>c>>s;

    if( c == n )
    {
        assert( k == 1 );
        int cnt = 0, pos = -1;
        for(int i=0;i<n;i++)
        {
            if( s[i] != 'x' )
            {
                cnt++;
                pos = i;
            }
        }
        if( cnt == 1 )
        {
            cout<<pos,nl;
        }
        return 0;
    }
    c++;

    vector<int>work(n+1,0), max_pref(n+1,0), suff_work(n+1,0), max_suff(n+1,0);
    for(int i=0;i<c;i++)
    {
        if( s[n-1-i] != 'x' )
            suff_work[n-1-i] = 1;
        else
            suff_work[n-1-i] = 0;
        max_suff[n-1-i] = max( max_suff[n-i], suff_work[n-1-i] );

        if( s[i] != 'x' )
            work[i] = 1;
        else
            work[i] = 0;
        max_pref[i] = max( ( i == 0 ? 0 : max_pref[i-1] ), work[i] );
    }
    for(int i=c;i<n;i++)
    {
        suff_work[n-1-i] = max_suff[n-1-i+c];
        if( s[n-1-i] != 'x' )
            suff_work[n-1-i]++;
        max_suff[n-1-i] = max( max_suff[n-i], suff_work[n-1-i] );

        work[i] = max_pref[i-c];
        if( s[i] != 'x' )
            work[i]++;
        max_pref[i] = max( max_pref[i-1], work[i] );
    }

    vector<int>total(n+1,0);
    for(int i=0;i<n;i++)
    {
        total[i] = max_pref[i];
        if( i + c < n )
            total[i] += max_suff[i+c];
    }

    multiset<int>st;
    for(int i=0;i<c;i++)
        st.insert(max_suff[i]);

    vector<int>ans;
    for(int i=0;i<n;i++)
    {
        if( i >= c )
        {
            auto it = st.find(total[i-c]);
            if( it != st.end() )
                st.erase(it);
        }
        else
        {
            auto it = st.find(max_suff[i]);
            if( it != st.end() )
                st.erase(it);
        }

        if( s[i] != 'x' && !st.empty() )
        {
            ll best = *(st.rbegin());
            if( best < k )
                ans.pb(i+1);
        }

        st.insert(total[i]);
        // if there exists x such that i - c < x < i, total[x] >= k
    }

    for( int x : ans )
        cout<<x,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Compiler output:
a.cc:10:18: error: expected initializer before 'ios_base'
   10 | #define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
      |                  ^~~~~~~~
a.cc:45:5: note: in expansion of macro 'fastio'
   45 |     fastio();
      |     ^~~~~~
a.cc:10:47: error: 'cin' does not name a type
   10 | #define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
      |                                               ^~~
a.cc:45:5: note: in expansion of macro 'fastio'
   45 |     fastio();
      |     ^~~~~~
a.cc:10:58: error: 'cout' does not name a type
   10 | #define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
      |                                                          ^~~~
a.cc:45:5: note: in expansion of macro 'fastio'
   45 |     fastio();
      |     ^~~~~~
a.cc:49:5: error: 'cin' does not name a type
   49 |     cin>>n>>k>>c>>s;
      |     ^~~
a.cc:51:5: error: expected unqualified-id before 'if'
   51 |     if( c == n )
      |     ^~
a.cc:69:5: error: 'c' does not name a type
   69 |     c++;
      |     ^
a.cc:72:5: error: expected unqualified-id before 'for'
   72 |     for(int i=0;i<c;i++)
      |     ^~~
a.cc:72:17: error: 'i' does not name a type
   72 |     for(int i=0;i<c;i++)
      |                 ^
a.cc:72:21: error: 'i' does not name a type
   72 |     for(int i=0;i<c;i++)
      |                     ^
a.cc:86:5: error: expected unqualified-id before 'for'
   86 |     for(int i=c;i<n;i++)
      |     ^~~
a.cc:86:17: error: 'i' does not name a type
   86 |     for(int i=c;i<n;i++)
      |                 ^
a.cc:86:21: error: 'i' does not name a type
   86 |     for(int i=c;i<n;i++)
      |                     ^
a.cc:100:5: error: expected unqualified-id before 'for'
  100 |     for(int i=0;i<n;i++)
      |     ^~~
a.cc:100:17: error: 'i' does not name a type
  100 |     for(int i=0;i<n;i++)
      |                 ^
a.cc:100:21: error: 'i' does not name a type
  100 |     for(int i=0;i<n;i++)
      |                     ^
a.cc:108:5: error: expected unqualified-id before 'for'
  108 |     for(int i=0;i<c;i++)
      |     ^~~
a.cc:108:17: error: 'i' does not name a type
  108 |     for(int i=0;i<c;i++)
      |                 ^
a.cc:108:21: error: 'i' does not name a type
  108 |     for(int i=0;i<c;i++)
      |                     ^
a.cc:112:5: error: expected unqualified-id before 'for'
  112 |     for(int i=0;i<n;i++)
      |     ^~~
a.cc:112:17: error: 'i' does not name a type
  112 |     for(int i=0;i<n;i++)
      |                 ^
a.cc:112:21: error: 'i' does not name a type
  112 |     for(int i=0;i<n;i++)
      |                     ^
a.cc:138:5: error: expected unqualified-id before 'for'
  138 |     for( int x : ans )
      |     ^~~
a.cc:141:5: error: 'cerr' does not name a type
  141 |     cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
      |     ^~~~
a.cc:142:5: error: expected unqualified-id before 'return'
  142 |     return 0;
      |     ^~~~~~
a.cc:143:1: error: expected declaration before '}' token
  143 | }
      | ^