Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
class One {
public:
    // 単位元
    T unit;
    
    One(void) {
        // 単位元
        unit = 0;
    }

    // 演算関数
    T calc(T a, T b, int num) {
        return (a==num)+(b==num); 
    }
};

template <typename T>
struct Sum {
public:
    // 単位元
    T unit;
    
    Sum(void) {
        // 単位元
        unit = 0;
    }

    // 演算関数
    T calc(T a, T b) {
        return (a + b); 
    }
};

class SegmentTree {
public:
    // セグメント木の葉の要素数
    int n;

    // セグメント木
    vector<int> tree;

    // モノイド
    Sum<int> mono1; // RAQ

    SegmentTree(vector<int> &v) : n(1 << (int)ceil(log2(v.size()))), tree(vector<int>(n << 1)) {
        for(int i = 0; i < v.size(); ++i) {
            update(i, v[i]);
        }
        for(int i = v.size(); i < n; ++i) {
            update(i, mono1.unit);
        }
    }

    // k番目の値(0-indexed)をxに変更
    void update(int k, int x) {
        k += n;
        tree[k] = x;
        for(k = k >> 1; k > 0; k >>= 1){
            tree[k] = mono1.calc(tree[k << 1 | 0], tree[k << 1 | 1], 0);
        }
    }

    // [l, r)の最小値(0-indexed)を求める．
    int query(int l, int r) {
        int res = mono1.unit;
        l += n;
        r += n;
        while(l < r) {
            if(l & 1) {
                res = mono1.calc(res, tree[l++]);
            }
            if(r & 1) {
                res = mono1.calc(res, tree[--r]);
            }
            l >>= 1;
            r >>= 1;
        }
        return res;
    }


    int operator[](int k) {
        // st[i]で添字iの要素の値を返す
        if(k - n >= 0 || k < 0) {
            return -INF;
        }
        return tree[tree.size() - n + k];
    }

    void show(void) {
        int ret = 2;
        for(int i = 1; i < 2*n; ++i) {
            if(tree[i] == INF) cout << "INF ";
            else cout << tree[i] << " ";
            if(i == ret - 1) {
                cout << endl;
                ret <<= 1;
            }
        }
        cout << endl;
    }
};

class SegmentTree3 {
public:
    // セグメント木の葉の要素数
    int n;

    // セグメント木
    vector<int> tree;

    // モノイド
    One<int> mono1; // RAQ

    SegmentTree(vector<int> &v) : n(1 << (int)ceil(log2(v.size()))), tree(vector<int>(n << 1)) {
        for(int i = 0; i < v.size(); ++i) {
            update(i, v[i]);
        }
        for(int i = v.size(); i < n; ++i) {
            update(i, mono1.unit);
        }
    }

    // k番目の値(0-indexed)をxに変更
    void update(int k, int x) {
        k += n;
        tree[k] = x;
        for(k = k >> 1; k > 0; k >>= 1){
            tree[k] = mono1.calc(tree[k << 1 | 0], tree[k << 1 | 1], 0);
        }
    }

    // [l, r)の最小値(0-indexed)を求める．
    int query(int l, int r) {
        int res = mono1.unit;
        l += n;
        r += n;
        while(l < r) {
            if(l & 1) {
                res = mono1.calc(res, tree[l++]);
            }
            if(r & 1) {
                res = mono1.calc(res, tree[--r]);
            }
            l >>= 1;
            r >>= 1;
        }
        return res;
    }


    int operator[](int k) {
        // st[i]で添字iの要素の値を返す
        if(k - n >= 0 || k < 0) {
            return -INF;
        }
        return tree[tree.size() - n + k];
    }
};


template <typename T, class MONOID>
class SegmentTree2 {
public:
    // セグメント木の葉の要素数
    int n;

    // セグメント木
    vector<T> tree;

    // モノイド
    MONOID mono1; // RAQ

    SegmentTree(vector<T> &v) : n(1 << (int)ceil(log2(v.size()))), tree(vector<T>(n << 1)) {
        for(int i = 0; i < v.size(); ++i) {
            update(i, v[i]);
        }
        for(int i = v.size(); i < n; ++i) {
            update(i, mono1.unit);
        }
    }

    // k番目の値(0-indexed)をxに変更
    void update(int k, T x) {
        k += n;
        tree[k] = x;
        for(k = k >> 1; k > 0; k >>= 1){
            tree[k] = mono1.calc(tree[k << 1 | 0], tree[k << 1 | 1]);
        }
    }

    T query(int l, int r, int num) {
        T res = mono1.unit;
        l += n;
        r += n;
        while(l < r) {
            if(l & 1) {
                res = mono1.calc(res, tree[l++], num,1);
            }
            if(r & 1) {
                res = mono1.calc(res, tree[--r], num,1);
            }
            l >>= 1;
            r >>= 1;
        }
        return res;
    }

    T operator[](int k) {
        // st[i]で添字iの要素の値を返す
        if(k - n >= 0 || k < 0) {
            return -INF;
        }
        return tree[tree.size() - n + k];
    }

    void show(void) {
        int ret = 2;
        for(int i = 1; i < 2*n; ++i) {
            if(tree[i] == INF) cout << "INF ";
            else cout << tree[i] << " ";
            if(i == ret - 1) {
                cout << endl;
                ret <<= 1;
            }
        }
        cout << endl;
    }
};
int main() {
    
    int n,k,c;
    string s;
    cin>>n>>k>>c>>s;
    vi zo(n+1,0);
    rep(i,n)cout<<zo[i]<<" ";
    cout<<endl;
    SegmentTree st(zo);

    rep(i,n){
        if(s[i]!='o')continue;
        int s=i+1, t=min(i+1+c, n-1);
        st.update(s, st[s]-1);
        st.update(t, st[t]+1);
    }
    vi v(n);
    rep(i,n){
        v[i]=st.query(0,i+1);
        if(v[i]==0&&s[i]=='o')v[i]=1;
    }

    vi ans;
    SegmentTree2<int,One<int>> st2(v);
    SegmentTree3<int,One<int>> st3(v);
    rep(i,n){
        if(st2[i]!=1)continue;
        st2.update(i,0);
        st3.update(i,0);
        int one=st2.calcNum(0,n,1);
        int zero=st3.calcNum(i+1,min(i+1+c, n),0);
        st2.update(i,1);
        st3.update(i,1);
        if(zero+one<k)ans.pb(i);
    }
    rep(i,ans.size()){
        if(!i)cout<<ans[i];
        else cout<<" "<<ans[i];
    }
    cout<<endl;
}



Compiler output:
a.cc: In member function 'void SegmentTree::update(int, int)':
a.cc:123:33: error: no matching function for call to 'Sum<int>::calc(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, int)'
  123 |             tree[k] = mono1.calc(tree[k << 1 | 0], tree[k << 1 | 1], 0);
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:93:7: note: candidate: 'T Sum<T>::calc(T, T) [with T = int]'
   93 |     T calc(T a, T b) {
      |       ^~~~
a.cc:93:7: note:   candidate expects 2 arguments, 3 provided
a.cc: At global scope:
a.cc:179:29: error: invalid declarator before '&' token
  179 |     SegmentTree(vector<int> &v) : n(1 << (int)ceil(log2(v.size()))), tree(vector<int>(n << 1)) {
      |                             ^
a.cc:179:28: error: expected ')' before '&' token
  179 |     SegmentTree(vector<int> &v) : n(1 << (int)ceil(log2(v.size()))), tree(vector<int>(n << 1)) {
      |                ~           ^~
      |                            )
a.cc: In member function 'int SegmentTree3::query(int, int)':
a.cc:204:33: error: no matching function for call to 'One<int>::calc(int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
  204 |                 res = mono1.calc(res, tree[l++]);
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~~~
a.cc:76:7: note: candidate: 'T One<T>::calc(T, T, int) [with T = int]'
   76 |     T calc(T a, T b, int num) {
      |       ^~~~
a.cc:76:7: note:   candidate expects 3 arguments, 2 provided
a.cc:207:33: error: no matching function for call to 'One<int>::calc(int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
  207 |                 res = mono1.calc(res, tree[--r]);
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~~~
a.cc:76:7: note: candidate: 'T One<T>::calc(T, T, int) [with T = int]'
   76 |     T calc(T a, T b, int num) {
      |       ^~~~
a.cc:76:7: note:   candidate expects 3 arguments, 2 provided
a.cc: At global scope:
a.cc:238:27: error: invalid declarator before '&' token
  238 |     SegmentTree(vector<T> &v) : n(1 << (int)ceil(log2(v.size()))), tree(vector<T>(n << 1)) {
      |                           ^
a.cc:238:26: error: expected ')' before '&' token
  238 |     SegmentTree(vector<T> &v) : n(1 << (int)ceil(log2(v.size()))), tree(vector<T>(n << 1)) {
      |                ~         ^~
      |                          )
a.cc: In function 'int main()':
a.cc:317:37: error: no matching function for call to 'SegmentTree2<int, One<int> >::SegmentTree2(vi&)'
  317 |     SegmentTree2<int,One<int>> st2(v);
      |                                     ^
a.cc:227:7: note: candidate: 'SegmentTree2<int, One<int> >::SegmentTree2()'
  227 | class SegmentTree2 {
      |       ^~~~~~~~~~~~
a.cc:227:7: note:   candidate expects 0 arguments, 1 provided
a.cc:227:7: note: candidate: 'SegmentTree2<int, One<int> >::SegmentTree2(const SegmentTree2<int, One<int> >&)'
a.cc:227:7: note:   no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'const SegmentTree2<int, One<int> >&'
a.cc:227:7: note: candidate: 'SegmentTree2<int, One<int> >::SegmentTree2(SegmentTree2<int, One<int> >&&)'
a.cc:227:7: note:   no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'SegmentTree2<int, One<int> >&&'
a.cc:318:5: error: 'SegmentTree3' is not a template
  318 |     SegmentTree3<int,One<int>> st3(v);
      |     ^~~~~~~~~~~~
a.cc:318:37: error: no matching function for call to 'SegmentTree3::SegmentTree3(vi&)'
  318 |     SegmentTree3<int,One<int>> st3(v);
      |                                     ^
a.cc:168:7: note: candidate: 'SegmentTree3::SegmentTree3()'
  168 | class SegmentTree3 {
      |       ^~~~~~~~~~~~
a.cc:168:7: note:   candidate expects 0 arguments, 1 provided
a.cc:168:7: note: candidate: 'SegmentTree3::SegmentTree3(const SegmentTree3&)'
a.cc:168:7: note:   no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'const SegmentTree3&'
a.cc:168:7: note: candidate: 'SegmentTree3::SegmentTree3(SegmentTree3&&)'
a.cc:168:7: note:   no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'SegmentTree3&&'
a.cc:323:21: error: 'class SegmentTree2<int, One<int> >' has no member named 'calcNum'
  323 |         int one=st2.calcNum(0,n,1);
      |                     ^~~~~~~
a.cc:324:22: error: 'class SegmentTree3' has no member named 'calcNum'
  324 |         int zero=st3.calcNum(i+1,min(i+1+c, n),0);
      |                      ^~~~~~~
a.cc: In instantiation of 'void SegmentTree2<T, MONOID>::update(int, T) [with T = int; MONOID = One<int>]':
a.cc:321:19:   required from here
  321 |         st2.update(i,0);
      |         ~~~~~~~~~~^~~~~
a.cc:252:33: error: no matching function for call to 'One<int>::calc(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
  252 |             tree[k] = mono1.calc(tree[k << 1 | 0], tree[k << 1 | 1]);
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:76:7: note: candidate: 'T One<T>::calc(T, T, int) [with T = int]'
   76 |     T calc(T a, T b, int num) {
      |       ^~~~
a.cc:76:7: note:   candidate expects 3 arguments, 2 provided