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

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int, int>>>

const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector<vector<ll>>; // Caution!! Segmentation Fault!! Don't forget
                                  // to add +1!

#define all(v) v.begin(), v.end()
#define output_s(a) printf("%s\\n", (a).c_str())

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define RepS(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define RRepS(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define RepA(x) for (auto &item : (x))

void CINT() {}
template <class Head, class... Tail> void CINT(Head &&head, Tail &&...tail) {
  cin >> head;
  CINT(move(tail)...);
}
#define CIN(...)                                                               \\
  int __VA_ARGS__;                                                             \\
  CINT(__VA_ARGS__)
#define LCIN(...)                                                              \\
  ll __VA_ARGS__;                                                              \\
  CINT(__VA_ARGS__)
#define SCIN(...)                                                              \\
  string __VA_ARGS__;                                                          \\
  CINT(__VA_ARGS__)

template <typename TypeInt> // 最大公約数
TypeInt GCD(TypeInt a, TypeInt b) {
  if (a % b == 0)
    return b;
  else
    return GCD(b, a % b);
}
template <typename TypeInt> // 最小公倍数
TypeInt LCM(TypeInt a, TypeInt b) {
  return a * b / GCD(a, b);
}

int IN_int() {
  int x;
  scanf("%d", &x);
  return x;
}

//----------------------library------------------------//

// const int dx[4]={1,0,-1,0};
// const int dy[4]={0,1,0,-1};
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

const int NMAX = 200;
bool flag;

bool comp(int x, int y) { return abs(0 - x) < abs(0 - y); }

signed main() {
  CIN(N, K, C);
  SCIN(s);
  vector<int> front(K), back(K);
  int cnt = 0;
  int i = 0;
  while (1) {
    if (s[i] == 'o') {
      front[cnt] = i;
      i = i + C + 1;
      cnt++;
    } else {
      i++;
    }
    if (i > N - 1 || cnt >= K)
      break;
  }
  cnt = K - 1;
  i = N - 1;
  while (1) {
    if (s[i] == 'o') {
      back[cnt] = i;
      i = i - C - 1;
      cnt--;
    } else {
      i--;
    }
    if (i < 0 || cnt < 0)
      break;
  }
  rep(i, K) {
    if (front[i] == back[i]) {
      printf("%d\\n", front[i] + 1);
    }
  }

  return 0;
}

Error: -11

Fixed submission:

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int, int>>>

const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector<vector<ll>>; // Caution!! Segmentation Fault!! Don't forget
                                  // to add +1!

#define all(v) v.begin(), v.end()
#define output_s(a) printf("%s\\n", (a).c_str())

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define RepS(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define RRepS(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define RepA(x) for (auto &item : (x))

void CINT() {}
template <class Head, class... Tail> void CINT(Head &&head, Tail &&...tail) {
  cin >> head;
  CINT(move(tail)...);
}
#define CIN(...)                                                               \\
  int __VA_ARGS__;                                                             \\
  CINT(__VA_ARGS__)
#define LCIN(...)                                                              \\
  ll __VA_ARGS__;                                                              \\
  CINT(__VA_ARGS__)
#define SCIN(...)                                                              \\
  string __VA_ARGS__;                                                          \\
  CINT(__VA_ARGS__)

template <typename TypeInt> // 最大公約数
TypeInt GCD(TypeInt a, TypeInt b) {
  if (a % b == 0)
    return b;
  else
    return GCD(b, a % b);
}
template <typename TypeInt> // 最小公倍数
TypeInt LCM(TypeInt a, TypeInt b) {
  return a * b / GCD(a, b);
}

int IN_int() {
  int x;
  scanf("%d", &x);
  return x;
}

//----------------------library------------------------//

// const int dx[4]={1,0,-1,0};
// const int dy[4]={0,1,0,-1};
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

const int NMAX = 200;
bool flag;

bool comp(int x, int y) { return abs(0 - x) < abs(0 - y); }
vi vec;
map<int, int> mp;
int cnt = 0;

vector<bool> seen;
void dfs(vector<int> &s, int v, int rest) {
  seen[v] = true;
  mp[v]++;
  for (auto next_v : s) {
    if (seen[next_v])
      continue;
    if (s[next_v] == 0)
      continue;
    dfs(s, next_v + rest, rest);
  }
  cnt++;
}

signed main() {
  CIN(N, K, C);
  SCIN(s);
  vector<int> vec(N);
  rep(i, N) {
    if (s[i] == 'x')
      vec[i] = 0;
    else
      vec[i] = 1;
  }
  seen.assign(N, false);
  RepS(i, 1, N) { dfs(vec, i, C); }
  rep(i, mp.size()) if (cnt == mp[i]) printf("%d\\n", i);

  return 0;
}