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

#include <algorithm>
#include <assert.h>
#include <cmath>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll v[710000], t[710000];
bool ok[710000];
int main() {
  ll n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  REP(i, n) ok[i] = true;
  REP(i, n) {
    if (s[i] == 'o')
      v[i + c + 1] = max(v[i + c + 1], v[i] + 1);
    v[i + 1] = max(v[i + 1], v[i]);
    // cout << i << " " << v[i] << endl;
  }
  REPR(i, n - 1) {
    if (s[i] == 'o')
      t[i] = max(t[i], t[i + c + 1] + 1);
    t[i] = max(t[i + 1], t[i]);
    // cout << i << " " << t[i] << endl;
  }
  REP(i, n) {
    ll now = 0;
    now += v[i];
    if (i + 1 < n)
      now += t[i + 1];
    if (now >= k)
      ok[i] = false;
    // cout << now << " " << i << endl;
  }
  ll now = 0, cnt = 0;
  REP(i, n) {
    if (s[i] == 'o' and cnt == 0) {
      now++;
      cnt = c;
      // cout << i << " !" << endl;
    } else {
      if (cnt > 0)
        cnt--;
      ok[i] = false;
    }
  }
  if (now > k)
    return 0;
  REP(i, n) {
    if (ok[i])
      cout << i + 1 << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <assert.h>
#include <cmath>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll v[110000], t[110000];
bool ok[110000];
int main() {
  ll n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  REP(i, n) ok[i] = true;
  REP(i, n) {
    if (s[i] == 'o')
      v[i + c] = max(v[i + c], v[i] + 1);
    v[i + 1] = max(v[i + 1], v[i]);
    // cout << i << " " << v[i] << endl;
  }
  REPR(i, n - 1) {
    if (s[i] == 'o')
      t[i] = max(t[i], t[i + c + 1] + 1);
    t[i] = max(t[i + 1], t[i]);
    // cout << i << " " << t[i] << endl;
  }
  REP(i, n) {
    ll now = 0;
    if (i - 1 >= 0)
      now += v[i - 1];
    if (i + 1 < n)
      now += t[i + 1];
    if (now >= k)
      ok[i] = false;
    // cout << now << " " << i << endl;
  }
  ll now = 0, cnt = 0;
  REP(i, n) {
    if (s[i] == 'o' and cnt == 0) {
      now++;
      cnt = c;
      // cout << i << " !" << endl;
    } else {
      if (cnt > 0)
        cnt--;
      ok[i] = false;
    }
  }
  if (now > k)
    return 0;
  REP(i, n) {
    if (ok[i])
      cout << i + 1 << endl;
  }
}