Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

/* snippet: useful macros and functions */
#define ARC(i, a, b) for (Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for (Int i = (a)-1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template <class T> T ant(const T &a, const T &b) { return a > b ? a : b; }
template <class T> T ont(const T &a, const T &b) { return a < b ? a : b; }
template <class T> T rng(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}
template <class T> void th(T &a, const T &b, T (*f)(const T &, const T &)) {
  a = f(a, b);
}
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template <class T, int MOD> class Modint {
  T val;

public:
  Modint(T val = 0) : val(val) {}
  operator T() { return val; }
  Modint &operator+=(const Modint &a) {
    val += a.val;
    if (val >= MOD)
      val -= MOD;
    return *this;
  }
  Modint &operator-=(const Modint &a) {
    val -= a.val;
    if (val < 0)
      val += MOD;
    return *this;
  }
  Modint &operator*=(const Modint &a) {
    val = val * a.val % MOD;
    return *this;
  }
  void inverse() {
    T x[2] = {MOD, val}, a[2] = {0, 1};
    int i;
    for (i = 0; x[!i]; i ^= 1) {
      a[i] -= x[i] / x[!i] * a[!i];
      x[i] = x[i] % x[!i];
    }
    if (!i)
      a[i] += MOD;
    val = a[i];
  }
  Modint &operator/=(Modint a) {
    a.inverse();
    return *this *= a;
  }
  friend Modint modpow(Modint a, int n) {
    Modint ret(1);
    while (n) {
      if (n & 1)
        ret *= a;
      a *= a;
      n >>= 1;
    }
    return ret;
  }
  friend Modint operator+(Modint a, const Modint &b) { return a += b; }
  friend Modint operator-(Modint a, const Modint &b) { return a -= b; }
  friend Modint operator*(Modint a, const Modint &b) { return a *= b; }
  friend Modint operator/(Modint a, const Modint &b) { return a /= b; }
  friend std::ostream &operator<<(std::ostream &os, const Modint &a) {
    return os << a.val;
  }
};

/* snippet: using declarations */
using Int = int;
using namespace std;
using Mint = Modint<long long, 1000000007>;

Int n, k, c;
char s[212345];
Int dp_f[412345], dp_b_[412345], *dp_b = dp_b_ + 212345;

int main() {
  cin >> n >> k >> c >> s;
  RCH(i, n) {
    if (s[i] == 'o') {
      dp_f[i] = ant(dp_f[i + 1], dp_f[i + c + 1] + 1);
    } else {
      dp_f[i] = dp_f[i + 1];
    }
  }
  RC(i, n) {
    if (s[i] == 'o') {
      dp_b[i] = ant(dp_b[i - 1], dp_b[i - c - 1] + 1);
    } else {
      dp_b[i] = dp_b[i - 1];
    }
  }
  // RC(i, n) cout << dp_f[i] << " "; cout << endl;
  // RC(i, n) cout << dp_b[i] << " "; cout << endl;
  RC(i, n) {
    if (dp_b[i - 1] + dp_f[i + 1] < k) {
      cout << i + 1 << endl;
    }
  }
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

/* snippet: useful macros and functions */
#define ARC(i, a, b) for (Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for (Int i = (a)-1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template <class T> T ant(const T &a, const T &b) { return a > b ? a : b; }
template <class T> T ont(const T &a, const T &b) { return a < b ? a : b; }
template <class T> T rng(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}
template <class T> void th(T &a, const T &b, T (*f)(const T &, const T &)) {
  a = f(a, b);
}
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template <class T, int MOD> class Modint {
  T val;

public:
  Modint(T val = 0) : val(val) {}
  operator T() { return val; }
  Modint &operator+=(const Modint &a) {
    val += a.val;
    if (val >= MOD)
      val -= MOD;
    return *this;
  }
  Modint &operator-=(const Modint &a) {
    val -= a.val;
    if (val < 0)
      val += MOD;
    return *this;
  }
  Modint &operator*=(const Modint &a) {
    val = val * a.val % MOD;
    return *this;
  }
  void inverse() {
    T x[2] = {MOD, val}, a[2] = {0, 1};
    int i;
    for (i = 0; x[!i]; i ^= 1) {
      a[i] -= x[i] / x[!i] * a[!i];
      x[i] = x[i] % x[!i];
    }
    if (!i)
      a[i] += MOD;
    val = a[i];
  }
  Modint &operator/=(Modint a) {
    a.inverse();
    return *this *= a;
  }
  friend Modint modpow(Modint a, int n) {
    Modint ret(1);
    while (n) {
      if (n & 1)
        ret *= a;
      a *= a;
      n >>= 1;
    }
    return ret;
  }
  friend Modint operator+(Modint a, const Modint &b) { return a += b; }
  friend Modint operator-(Modint a, const Modint &b) { return a -= b; }
  friend Modint operator*(Modint a, const Modint &b) { return a *= b; }
  friend Modint operator/(Modint a, const Modint &b) { return a /= b; }
  friend std::ostream &operator<<(std::ostream &os, const Modint &a) {
    return os << a.val;
  }
};

/* snippet: using declarations */
using Int = int;
using namespace std;
using Mint = Modint<long long, 1000000007>;

Int n, k, c;
char s[212345];
Int dp[2][212345];

int main() {
  cin >> n >> k >> c >> s;
  RC(i, n) {
    if (s[i] == 'o') {
      dp[0][i] = ant(dp[0][i - 1], dp[0][i - c - 1] + 1);
    } else {
      dp[0][i] = dp[0][i - 1];
    }
  }
  RCH(i, n) {
    if (s[i] == 'o') {
      dp[1][i] = ant(dp[1][i + 1], dp[1][i + c + 1] + 1);
    } else {
      dp[1][i] = dp[1][i + 1];
    }
  }
  RC(i, n) {
    if (dp[0][i - 1] + dp[1][i + 1] < k) {
      cout << i + 1 << endl;
    }
  }
}