Problem:
Score : 500 points

Problem Statement

Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.

You are given an integer C and a string S. Takahashi will choose his workdays as follows:

After working for a day, he will refrain from working on the subsequent C days.

If the i-th character of S is x, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.

Find all days on which Takahashi is bound to work.

Constraints

1 \leq N \leq 2 \times 10^5

1 \leq K \leq N

0 \leq C \leq N

The length of S is N.

Each character of S is o or x.

Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.

Input

Input is given from Standard Input in the following format:

N K C
S

Output

Print all days on which Takahashi is bound to work in ascending order, one per line.

Sample Input 1

11 3 2
ooxxxoxxxoo

Sample Output 1

6

Takahashi is going to work on 3 days out of the 11 days. After working for a day, he will refrain from working on the subsequent 2 days.

There are four possible choices for his workdays: Day 1,6,10, Day 1,6,11, Day 2,6,10, and Day 2,6,11.

Thus, he is bound to work on Day 6.

Sample Input 2

5 2 3
ooxoo

Sample Output 2

1
5

There is only one possible choice for his workdays: Day 1,5.

Sample Input 3

5 1 0
ooooo

Sample Output 3

There may be no days on which he is bound to work.

Sample Input 4

16 4 3
ooxxoxoxxxoxoxxo

Sample Output 4

11
16

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

template <class I>
class SegmentTree {
 public:
  using Op = function<I(const I&, const I&)>;

 private:
  int n;
  vector<I> dat;
  Op op;
  I e;

 public:
  SegmentTree(int n_, const Op& op, const I& e) : op(op), e(e) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, e);
  }
  SegmentTree(const vector<I>& init, const Op& op, const I& e)
      : SegmentTree(init.size(), op, e) {
    for (int i = 0; i < init.size(); i++) {
      dat[i + n - 1] = init[i];
    }
    for (int i = n - 2; i >= 0; i--) {
      dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
  }
  const I& operator[](int k) const { return dat[k + n - 1]; }
  void update(int k, const I& a) {
    k += n - 1;
    dat[k] = op(dat[k], a);
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = op(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }
  // [a, b)
  I query(int a, int b) const {
    a += n - 1;
    b += n - 1;
    I vl = e;
    I vr = e;
    while (a < b) {
      if ((a & 1) == 0) vl = op(vl, dat[a]);
      if ((b & 1) == 0) vr = op(dat[b - 1], vr);
      a = a / 2;
      b = (b - 1) / 2;
    }
    return op(vl, vr);
  }
  // query(0, i) >= x 縺ｨ縺ｪ繧区怙蟆上�ｮi
  int kth(const I& x) const {
    int k = 0;
    I v = e;
    while (k < n - 1) {
      I t = op(v, dat[k * 2 + 1]);
      if (x <= t) {
        k = k * 2 + 1;
      } else {
        v = t;
        k = k * 2 + 2;
      }
    }
    return k - (n - 1) + 1;
  }
};

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, K, C;
  string S;
  while (cin >> N >> K >> C >> S) {
    vector<int> dpL(N, 0), dpR(N, 0);
    for (int i = 0; i < N; i++) {
      if (i - 1 >= 0) chmax(dpL[i], dpL[i - 1]);
      if (S[i] == 'o') {
        chmax(dpL[i], 1);
        if (i - C - 1 >= 0) chmax(dpL[i], dpL[i - C - 1] + 1);
      }
    }
    for (int i = N - 1; i >= 0; i--) {
      if (i + 1 < N) chmax(dpR[i], dpR[i + 1]);
      if (S[i] == 'o') {
        chmax(dpR[i], 1);
        if (i + C + 1 < N) chmax(dpR[i], dpR[i + C + 1] + 1);
      }
    }
    auto op = [&](int a, int b) { return max(a, b); };
    SegmentTree<int> seg(N, op, 0), ind(N, op, -1);
    vector<int> res;
    for (int i = 0; i < N; i++) {
      if (S[i] == 'x') continue;
      int mx = 0;
      if (i - 1 >= 0) chmax(mx, dpL[i - 1]);
      if (i + 1 < N) chmax(mx, dpR[i + 1]);
      if (i + 1 < N) {
        chmax(mx, seg.query(i + 1, N));
        int j = ind.query(0, i + 2);
        if (j >= 0) chmax(mx, dpL[j] + dpR[i + 1]);
      }
      if (i + C + 1 < N) {
        seg.update(i + C + 1, dpL[i] + dpR[i + C + 1]);
        ind.update(i + C + 1, i);
      }
      if (mx < K) res.push_back(i);
    }
    for (int x : res) cout << x + 1 << endl;
  }
  return 0;
}