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

// This program is written by Brian Peng.
#pragma GCC optimize("Ofast", "inline", "no-stack-protector")
#include <bits/stdc++.h>
using namespace std;
#define Rd(a) (a = read())
#define Gc(a) (a = getchar())
#define Pc(a) putchar(a)
int read() {
  int x;
  char c(getchar());
  bool k;
  while (!isdigit(c) && c ^ '-')
    if (Gc(c) == EOF)
      exit(0);
  c ^ '-' ? (k = 1, x = c & 15) : k = x = 0;
  while (isdigit(Gc(c)))
    x = (x << 1) + (x << 3) + (c & 15);
  return k ? x : -x;
}
void wr(int a) {
  if (a < 0)
    Pc('-'), a = -a;
  if (a <= 9)
    Pc(a | '0');
  else
    wr(a / 10), Pc((a % 10) | '0');
}
signed const INF(0x3f3f3f3f), NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL), LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\\n')
#define Frn0(i, a, b) for (int i(a); i < (b); ++i)
#define Frn1(i, a, b) for (int i(a); i <= (b); ++i)
#define Frn_(i, a, b) for (int i(a); i >= (b); --i)
#define Mst(a, b) memset(a, b, sizeof(a))
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)
#define N (200010)
int n, k, c, f[N], g[N], st[N], e[N], p(1);
char s[N];
stack<int> ans;
signed main() {
  Rd(n), Rd(k), Rd(c), cin >> s + 1, Mst(g, 0x3f);
  Frn1(i, 1, n) {
    if (i > c + 1)
      p = max(p, f[i - c - 1] + 1);
    if (s[i] == 'o') {
      if (p > k)
        exit(0);
      f[i] = p;
    }
  }
  Frn_(i, n, 1) {
    if (i + c < n)
      p = min(p, g[i + c + 1] - 1);
    if (s[i] == 'o')
      g[i] = p;
  }
  Frn1(i, 1, n) if (f[i] == g[i]) e[f[i]] = i;
  Frn_(i, n, 1) if (f[i] == g[i]) st[f[i]] = i;
  Frn1(i, 1, k) if (st[i] == e[i]) wr(st[i]), Pe;
  exit(0);
}

Error: 0

Fixed submission:

// This program is written by Brian Peng.
#pragma GCC optimize("Ofast", "inline", "no-stack-protector")
#include <bits/stdc++.h>
using namespace std;
#define Rd(a) (a = read())
#define Gc(a) (a = getchar())
#define Pc(a) putchar(a)
int read() {
  int x;
  char c(getchar());
  bool k;
  while (!isdigit(c) && c ^ '-')
    if (Gc(c) == EOF)
      exit(0);
  c ^ '-' ? (k = 1, x = c & 15) : k = x = 0;
  while (isdigit(Gc(c)))
    x = (x << 1) + (x << 3) + (c & 15);
  return k ? x : -x;
}
void wr(int a) {
  if (a < 0)
    Pc('-'), a = -a;
  if (a <= 9)
    Pc(a | '0');
  else
    wr(a / 10), Pc((a % 10) | '0');
}
signed const INF(0x3f3f3f3f), NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL), LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\\n')
#define Frn0(i, a, b) for (int i(a); i < (b); ++i)
#define Frn1(i, a, b) for (int i(a); i <= (b); ++i)
#define Frn_(i, a, b) for (int i(a); i >= (b); --i)
#define Mst(a, b) memset(a, b, sizeof(a))
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)
#define N (200010)
int n, k, c, f[N], g(1), st[N]{-1}, e[N], sm[N];
char s[N];
signed main() {
  Rd(n), Rd(k), Rd(c), cin >> s + 1;
  Frn1(i, 1, n) {
    sm[i] = sm[i - 1] + (s[i] == 'o');
    if (i > c + 1)
      g = max(g, f[i - c - 1] + 1);
    if (s[i] == 'o')
      e[f[i] = g] = i, st[g] ? 0 : (st[g] = i);
  }
  if (g > k)
    exit(1);
  Frn0(i, 1, k) if (sm[e[i + 1] - c - 1] == sm[st[i]]) wr(st[i]), Pe;
  if (st[k] == e[k])
    wr(st[k]);
  exit(0);
}