alexjercan/bugnet huggingface dataset:
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

// #define DEBUG

#ifdef DEBUG
using std::endl;
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#endif // DEBUG
#ifndef DEBUG
using namespace std;
#endif // DEBUG

template <class T> void print_vect(std::vector<T> v) {
  for (int i = 0; i < v.size(); i++)
    cout << v[i] << " ";
  cout << endl;
}

void yuttori() {
  unsigned int N, K, C;
  std::string S;
  cin >> N >> K >> C;
  cin >> S;
  std::vector<int> L, R;
  L.reserve(K);
  R.reserve(K);
  // fill L
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'o') {
      count++;
      L.push_back(i);
      i += C;
      // problem says it will reach this point
      if (count == K)
        break;
    }
  }
  // print_vect(L);

  // fill R
  count = 0;
  for (int i = N - 1; i >= 0; i--) {
    if (S[i] == 'o') {
      count++;
      R.push_back(i);
      i -= C;
      if (count == K)
        break;
    }
  }
  // print_vect(R);
  int i = 0;
  int j = K - 1;
  if (R[0] - L[K - 1] > C) {
    return;
  }
  while (i < K && j >= 0) {
    if (L[i] < R[j]) {
      i++;
    } else if (L[i] == R[j]) {
      cout << L[i] + 1 << endl;
      i++;
      j--;
    } else {
      j--;
    }
  }
}

int main() {
  // making data IO Fast
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  /****************************/

#ifdef DEBUG
  int TEST_CASES = 4;
  while (TEST_CASES--) {
#endif // DEBBUG

    yuttori();

#ifdef DEBUG
  }
#endif // DEBUG

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

bool get_K(std::string &S, int K, int C) {
  int count = 0;
  unsigned int i = 0;
  while (i < S.size()) {
    if (S[i] == 'o') {
      count++;
      if (count == K)
        break;
      i += C + 1;
    } else {
      i++;
    }
  }
  return (count >= K);
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  unsigned int N, K, C;
  std::string S;
  std::cin >> N >> K >> C;
  std::cin >> S;
  for (unsigned int i = 0; i < N; i++) {
    if (S[i] == 'o') {
      S[i] = 'x';
      if (!get_K(S, K, C)) {
        S[i] = 'o';
        std::cout << i + 1 << std::endl;
        i += C;
      } else {
        S[i] = 'o';
      }
    }
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define PI 3.14159265359
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool ss[200000];
int l[200001];
int r[200001];

int main() {
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  rep(i, n) ss[i] = (s[i] == 'x') ? false : true;

  int cnt = 0, i = 0;
  l[0] = 0;
  while (i < n) {
    if (ss[i]) {
      cnt++;
      int j = 0;
      while ((i < n) && (j < c + 1)) {
        l[i + 1] = cnt;
        i++;
        j++;
      }
      while ((i < n) && (!ss[i])) {
        l[i + 1] = cnt;
        i++;
      }
    } else {
      l[i + 1] = cnt;
      i++;
    }
  }

  cnt = k + 1;
  i = n - 1;
  r[n] = k + 1;
  while (i >= 0) {
    if (ss[i]) {
      cnt--;
      int j = 0;
      while ((i >= 0) && (j < c + 1)) {
        r[i] = cnt;
        i--;
        j++;
      }
      while ((i >= 0) && (!ss[i])) {
        r[i] = cnt;
        i--;
      }
    } else {
      r[i] = cnt;
      i--;
    }
  }

  // rep(i, n+1) cout << l[i] << " "; cout << endl;
  // rep(i, n+1) cout << r[i] << " "; cout << endl;

  rep(i, n) {
    if (r[i + 1] - l[i] == 2)
      cout << i + 1 << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define PI 3.14159265359
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool ss[200000];
int l[200001];
int r[200001];

int main() {
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  rep(i, n) ss[i] = (s[i] == 'x') ? false : true;

  int cnt = 1, i = 0;
  l[0] = 0;
  while (i < n) {
    if (ss[i]) {
      int j = 0;
      while ((i < n) && (j < c + 1)) {
        l[i + 1] = cnt;
        i++;
        j++;
      }
      while ((i < n) && (!ss[i])) {
        l[i + 1] = cnt;
        i++;
      }
      cnt++;
    }
  }

  cnt = k;
  i = n - 1;
  r[n] = k + 1;
  while (i >= 0) {
    if (ss[i]) {
      int j = 0;
      while ((i >= 0) && (j < c + 1)) {
        r[i] = cnt;
        i--;
        j++;
      }
      while ((i >= 0) && (!ss[i])) {
        r[i] = cnt;
        i--;
      }
      cnt--;
    }
  }

  // rep(i, n+1) cout << l[i] << " "; cout << endl;
  // rep(i, n+1) cout << r[i] << " "; cout << endl;

  rep(i, n) {
    if (r[i + 1] - l[i] == 2)
      cout << i + 1 << endl;
  }

  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;
using ll = long long;

int main() {
  int n, k, c;
  string s;
  int count = 0;
  cin >> n >> k >> c >> s;
  vector<int> d(k), f(k);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      d[count] = i;
      count++;
      i += c;
      if (count == k)
        break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'o') {
      count--;
      f[count] = i;
      i -= c;
      if (count == 0)
        break;
    }
  }
  bool nun = true;
  rep(i, k) {
    if (d[i] == f[i]) {
      cout << d[i] + 1 << endl;
      nun = false;
    }
  }
  if (nun)
    cout << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;
using ll = long long;

int main() {
  int n, k, c;
  string s;
  int count = 0;
  cin >> n >> k >> c >> s;
  vector<int> d;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      count++;
      d.push_back(i);
      i += c;
    }
  }
  if (count > k) {
    cout << endl;
    return 0;
  }
  for (int i = 0; i < k; i++) {
    count = 0;
    for (int j = 0; j < n; j++) {
      if (j != d[i] && s[j] == 'o') {
        count++;
        j += c;
      }
    }
    if (count == k)
      continue;
    cout << d[i] + 1 << endl;
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int n, k, c;
string s;
int a[200005], b[200005];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  //    freopen("input.txt","r",stdin);
  //    freopen("output.txt","w",stdout);

  cin >> n >> k >> c >> s;

  int id = 0;
  for (int i = 0; i < n;) {
    if (s[i] == 'o')
      a[id++] = i, i += c + 1;
    else
      i++;
    if (id == k)
      break;
  }

  id = k - 1;
  for (int i = n - 1; i >= 0;) {
    if (s[i] == 'o')
      b[id--] = i, i -= (c + 1);
    else
      i--;
    if (id == -1)
      break;
  }

  for (int i = 0; i < k; i++) {
    if (a[i] == b[i])
      cout << a[i] + 1 << '\\n';
  }
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int n, k, c;
string s;
int a[200005], b[200005];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  //    freopen("input.txt","r",stdin);
  //    freopen("output.txt","w",stdout);

  cin >> n >> k >> c >> s;

  int id = 0;
  for (int i = 0; i < n;) {
    if (s[i] == 'o')
      a[id++] = i, i += c + 1;
    else
      i++;
  }

  id = k - 1;
  for (int i = n - 1; i >= 0;) {
    if (s[i] == 'o')
      b[id--] = i, i -= (c + 1);
    else
      i--;
  }

  for (int i = 0; i < k; i++) {
    if (a[i] == b[i])
      cout << a[i] + 1 << '\\n';
  }
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define int long long
using namespace std;
int test[12345678], test1[12345678];
signed main() {
  int n, k, c, cnt = 1, mae = 0;
  string s;
  cin >> n >> k >> c >> s;
  for (int h = 0; h < n; h++) {
    if (s[h] == 'o') {
      if (cnt == 1) {
        test[cnt] = h + 1;
        cnt++;
        mae = h;
      } else if (h - mae > c) {
        test[cnt] = h + 1;
        cnt++;
        mae = h;
      }
    }
    if (cnt > k) {
      break;
    }
  }
  cnt = k;
  for (int h = n - 1; h >= 0; h--) {
    if (s[h] == 'o') {
      if (cnt == k) {
        test1[cnt] = h + 1;
        cnt--;
        mae = h;
      } else if (mae - h > c) {
        test1[cnt] = h + 1;
        cnt--;
        mae = h;
      }
    }
    if (cnt == 0) {
      break;
    }
  }
  for (int h = 1; h <= k; h++) {
    if (test[h] == test1[h]) {
      cout << test[h] << endl;
    }
  }
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
#define int long long
using namespace std;
int test[12345678], test1[12345678];
signed main() {
  int n, k, c, cnt = 1, mae = 0;
  string s;
  cin >> n >> k >> c >> s;
  for (int h = 0; h < n; h++) {
    if (s[h] == 'o') {
      if (cnt == 1) {
        test[cnt] = h + 1;
        cnt++;
        mae = h;
        continue;
      }
      if (h - mae > c) {
        test[cnt] = h + 1;
        cnt++;
        mae = h;
      }
    }
    if (cnt > k) {
      break;
    }
  }
  cnt = k;
  for (int h = n - 1; h >= 0; h--) {
    if (s[h] == 'o') {
      if (cnt == k) {
        test1[cnt] = h + 1;
        cnt--;
        mae = h;
        continue;
      }
      if (mae - h > c) {
        test1[cnt] = h + 1;
        cnt--;
        mae = h;
      }
    }
    if (cnt == 0) {
      break;
    }
  }
  for (int h = 1; h <= k; h++) {
    if (test[h] == test1[h]) {
      cout << test[h] << endl;
    }
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < n; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
#define LL long long
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD = 1e9 + 7;

int n, t, c, pos, vis[200010], sz = 0;
string s;
vector<int> v;

int main() {
  cin >> n >> t >> c >> s;
  pos = 0;
  while (s[pos] == 'x')
    pos++;
  while (pos < n) {
    sz++;
    vis[pos] = sz;
    pos += c + 1;
    while (pos < n && s[pos] == 'x')
      pos++;
  }
  pos = n - 1;
  while (s[pos] == 'x')
    pos--;
  while (pos >= 0) {
    v.pb(pos);
    pos -= c + 1;
    while (pos >= 0 && s[pos] == 'x')
      pos--;
  }
  reverse(v.begin(), v.end());
  rep(i, n) {
    if (vis[i] == 0)
      continue;
    int cur = vis[i] - 1, pos = upper_bound(v.begin(), v.end(), i) - v.begin();
    if (cur + v.size() - pos < t)
      cout << i + 1 << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < n; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
#define LL long long
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD = 1e9 + 7;

int n, t, c, pos, vis[100010], sz = 0;
string s;
vector<int> v;

int main() {
  cin >> n >> t >> c >> s;
  pos = 0;
  while (s[pos] == 'x')
    pos++;
  while (pos < n) {
    sz++;
    vis[pos] = sz;
    pos += c + 1;
    while (pos < n && s[pos] == 'x')
      pos++;
  }
  pos = n - 1;
  while (s[pos] == 'x')
    pos--;
  while (pos >= 0) {
    v.pb(pos);
    pos -= c + 1;
    while (pos >= 0 && s[pos] == 'x')
      pos--;
  }
  reverse(v.begin(), v.end());
  rep(i, n) {
    if (vis[i] == 0)
      continue;
    int cur = vis[i] - 1, pos = upper_bound(v.begin(), v.end(), i) - v.begin();
    if (cur + v.size() - pos < t)
      cout << i + 1 << endl;
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

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

int main(void) {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<int> L(K);
  vector<int> R(K);
  int k = 0;
  for (int i = 0; i < N;) {
    if (S[i] == 'o') {
      L[k++] = i;
      i += C + 1;
    } else {
      i++;
    }
    if (k == K) {
      break;
    }
  }
  k = K - 1;
  for (int i = N - 1; i >= 0;) {
    if (S[i] == 'o') {
      R[k--] = i;
      i -= C + 1;
    } else {
      i--;
    }
    if (k == -1) {
      break;
    }
  }
  for (int i = 0; i < K; i++) {
    if (L[i] == R[i]) {
      cout << L[i] + 1 << endl;
    }
  }

  return 0;
}

Error: 0

Fixed submission:

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

int main(void) {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<int> L(K);
  vector<ll> R(K);
  int k = 0;
  for (int i = 0; i < N;) {
    if (S[i] == 'o') {
      L[k++] = i;
      i += C + 1;
    } else {
      i++;
    }
  }
  k = K - 1;
  for (int i = N - 1; i >= 0;) {
    if (S[i] == 'o') {
      R[k--] = i;
      i -= C + 1;
    } else {
      i--;
    }
  }
  for (int i = 0; i < K; i++) {
    if (L[i] == R[i]) {
      cout << L[i] + 1 << endl;
    }
  }

  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) rep(i, 0, n)

void solve() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vector<bool> f(n, 0);
  int sum = 0;
  REP(i, s.size()) {
    if (s[n - 1 - i] == 'o') {
      sum++;
      f[n - 1 - i] = 1;
      i += c;
    }
  }
  if (sum > k) {
    return;
  }
  REP(i, s.size()) {
    if (s[i] == 'o') {
      if (f[i] == 1) {
        cout << i + 1 << endl;
      }
      i += c;
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) rep(i, 0, n)

void solve() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  REP(i, s.size()) {
    if (s[i] == 'o') {
      int sum = 0;
      REP(j, s.size()) {
        if (j != i && s[j] == 'o') {
          sum++;
          j += c;
        }
        if (sum >= k) {
          break;
        }
      }
      if (sum < k)
        cout << i + 1 << endl;
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

const int INF = 1000000009;
const int MAXN = 2 * 100 * 1000;

char tab[MAXN + 3];
int ff[2 * MAXN + 3], bb[2 * MAXN + 3];

int main() {
  int n, k, c;
  scanf("%d %d %d", &n, &k, &c);
  scanf("%s", tab + 1);
  for (int i = n; i >= 1; i--)
    if (tab[i] == 'o')
      ff[i] = 1 + ff[min(n + 1, i + c + 1)];
    else
      ff[i] = ff[i + 1];
  vector<int> ans;
  int last = -c;
  for (int i = 1; i <= n; i++) {
    if (tab[i] == 'o') {
      if (bb[max(last, 0)] + ff[max(i + 1, last + c + 1)] < k)
        ans.pb(i);
      if (i > last + c) {
        bb[i] = bb[max(last, 0)] + 1;
        last = i;
      }
    }
  }

  for (auto a : ans)
    printf("%d\\n", a);

  return 0;
}

Error: 0

Fixed submission:

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

const int INF = 1000000009;
const int MAXN = 2 * 100 * 1000;

char tab[MAXN + 3];
int ff[2 * MAXN + 3], bb[2 * MAXN + 3];

int main() {
  int n, k, c;
  scanf("%d %d %d", &n, &k, &c);
  scanf("%s", tab + 1);
  for (int i = n; i >= 1; i--)
    if (tab[i] == 'o')
      ff[i] = 1 + ff[min(n + 1, i + c + 1)];
    else
      ff[i] = ff[i + 1];
  vector<int> ans;
  int last = -c;
  for (int i = 1; i <= n; i++) {
    if (tab[i] == 'o') {
      if (bb[last] + ff[max(i + 1, last + c + 1)] < k)
        ans.pb(i);
      if (i > last + c) {
        bb[i] = bb[max(last, 0)] + 1;
        last = i;
      }
    }
  }

  for (auto a : ans)
    printf("%d\\n", a);

  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ((int)(x).size())

typedef long long ll;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, K, C;
  cin >> N >> K >> C;

  string s;
  cin >> s;

  vector<int> dp(N + 1);
  dp[N] = 0;
  for (int i(N - 1); i >= 0; --i) {
    dp[i] = dp[i + 1];
    if (s[i] == 'o')
      dp[i] = max(dp[i], 1 + dp[min(N, i + C + 1)]);
  }

  int l(0);
  while (l < N and K > 0) {
    int r = l;
    int cnt(0);
    while (r < N and dp[r] >= K and cnt <= 1) {
      cnt += s[r++] == 'o';
    }
    if (cnt == 1)
      for (int i(l); i < r; ++i)
        if (s[i] == 'o') {
          cout << i + 1 << '\\n';
          break;
        }
    --K;
    for (int i(l); i < r; ++i)
      if (s[i] == 'o') {
        l = i + C + 1;
        break;
      }
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ((int)(x).size())

typedef long long ll;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, K, C;
  cin >> N >> K >> C;

  string s;
  cin >> s;

  vector<int> dp(N + 1);
  dp[N] = 0;
  for (int i(N - 1); i >= 0; --i) {
    dp[i] = dp[i + 1];
    if (s[i] == 'o')
      dp[i] = max(dp[i], 1 + dp[min(N, i + C + 1)]);
  }

  int l(0);
  while (l < N and K > 0) {
    int r = l;
    int cnt(0);
    while (r < N and dp[r] >= K) {
      cnt += s[r++] == 'o';
    }
    if (cnt == 1)
      for (int i(l); i < r; ++i)
        if (s[i] == 'o') {
          cout << i + 1 << '\\n';
          break;
        }
    --K;
    for (int i(l); i < r; ++i)
      if (s[i] == 'o') {
        l = i + C + 1;
        break;
      }
  }
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define for_(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()
#define INIT(a, b) memset(a, b, sizeof(a))
using lint = long long int;

int N, K, C;
string S;

int main() {
  cin >> N >> K >> C;
  cin >> S;

  vector<int> a(N, 0);
  int thr = 0;
  for_(i, 0, N) {
    if (i < thr)
      continue;
    if (S[i] == 'o') {
      a[i] = 1;
      thr = i + C + 1;
    }
  }

  if (accumulate(ALL(a), int()) > K) {
    return 0;
  }

  reverse(ALL(S));
  vector<int> b(N, 0);
  thr = 0;
  int cnt = 0;
  for_(i, 0, N) {
    if (i < thr)
      continue;
    if (S[i] == 'o') {
      b[i] = 1;
      thr = i + C + 1;
      ++cnt;
    }
    if (cnt == K)
      break;
  }
  reverse(ALL(b));

  // reverse(ALL(S));
  // for_(i,0,N) cerr << S[i] << " ";
  // cerr << endl;
  // for_(i,0,N) cerr << a[i] << " ";
  // cerr << endl;
  // for_(i,0,N) cerr << b[i] << " ";
  // cerr << endl;

  for_(i, 0, N) if (a[i] == 1 and b[i] == 1) cout << i + 1 << endl;
}

Error: TLE

Fixed submission:

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

#define for_(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()
#define INIT(a, b) memset(a, b, sizeof(a))
using lint = long long int;

int N, K, C;
string S;

int main() {
  cin >> N >> K >> C;
  cin >> S;

  vector<int> nxt(N + 1, 1L << 30);
  for (int i = N - 1; i >= 0; --i) {
    if (S[i] == 'o')
      nxt[i] = i;
    else
      nxt[i] = nxt[i + 1];
  }

  auto check = [&](int x) {
    int day = 0, cnt = 0;
    while (day < N and cnt < K) {
      if (day == x)
        ++day;
      else if (nxt[day] == day) {
        ++cnt;
        day += C + 1;
      } else {
        day = nxt[day];
      }
    }
    return cnt >= K;
  };

  for_(i, 0, N) {
    if (S[i] == 'x')
      continue;
    if (!check(i))
      cout << i + 1 << endl;
  }
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;

  int backcount = k;
  vector<int> v(n + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (s.at(i) == 'o') {
      v.at(backcount) = i;
      backcount--;
      i -= c;
    }
    if (backcount == 0) {
      break;
    }
    if (i < 0) {
      return 0;
    }
  }

  int frontcount = 1;
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'o') {
      if (v.at(frontcount) == i) {
        cout << i + 1 << endl;
      }
      frontcount++;
      i += c;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;

  int backcount = k;
  vector<int> v(n);
  for (int i = n - 1; i >= 0; i--) {
    if (s.at(i) == 'o') {
      v.at(backcount) = i;
      backcount--;
      i -= c;
    }
    if (backcount == 0) {
      break;
    }
    if (i < 0) {
      return 0;
    }
  }

  int frontcount = 1;
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'o') {
      if (v.at(frontcount) == i) {
        cout << i + 1 << endl;
      }
      frontcount++;
      i += c;
    }
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <stdio.h>
#include <utility>
using namespace std;
typedef pair<int, int> pii;
pii ldp[200001], rdp[200001];
char txt[200001];
int main() {
  int N, K, C;
  scanf("%d %d %d", &N, &K, &C);
  scanf("%s", txt);
  if (txt[0] == 'o')
    ldp[0] = {1, 0};
  if (txt[N - 1] == 'o')
    rdp[N - 1] = {1, N - 1};
  for (int i = 1; i < N; i++) {
    if (txt[i] == 'o') {
      pii x = ldp[i - 1];
      pii y = {(i - C - 1 >= 0 ? ldp[i - C - 1].first : 0) + 1, i};
      if (x.first < y.first)
        ldp[i] = y;
      else
        ldp[i] = x;
    } else
      ldp[i] = ldp[i - 1];
  }
  for (int i = N - 2; i >= 0; i--) {
    if (txt[i] == 'o') {
      pii x = rdp[i + 1];
      pii y = {(i + C + 1 < N ? rdp[i + C + 1].first : 0) + 1, i};
      if (x.first < y.first)
        rdp[i] = y;
      else
        rdp[i] = x;
    } else
      rdp[i] = rdp[i + 1];
  }
  for (int i = 0; i < N; i++) {
    if (txt[i] != 'o')
      continue;
    int sum = 0;
    if (i > 0) {
      sum += ldp[i - 1].first;
      if (max(i + 1, ldp[i - 1].second + C + 1) < N)
        sum += rdp[max(i + 1, ldp[i - 1].second + C + 1)].first;
    }
    sum = max(i + 1 < N ? rdp[i + 1].first : 0, sum);
    // printf("%d %d\\n",i,sum);
    if (sum < K)
      printf("%d\\n", i + 1);
  }
}

Error: -11

Fixed submission:

#include <stdio.h>
#include <utility>
using namespace std;
typedef pair<int, int> pii;
pii ldp[200001], rdp[200001];
char txt[200001];
int main() {
  int N, K, C;
  scanf("%d %d %d", &N, &K, &C);
  scanf("%s", txt);
  if (txt[0] == 'o')
    ldp[0] = {1, 0};
  if (txt[N - 1] == 'o')
    rdp[N - 1] = {1, N - 1};
  for (int i = 1; i < N; i++) {
    if (txt[i] == 'o') {
      pii x = ldp[i - 1];
      pii y = {(i - C - 1 >= 0 ? ldp[i - C - 1].first : 0) + 1, i};
      if (x.first < y.first)
        ldp[i] = y;
      else
        ldp[i] = x;
    }
  }
  for (int i = N - 2; i >= 0; i++) {
    if (txt[i] == 'o') {
      pii x = rdp[i + 1];
      pii y = {(i + C + 1 < N ? rdp[i + C + 1].first : 0) + 1, i};
      if (x.first < y.first)
        rdp[i] = y;
      else
        rdp[i] = x;
    }
  }
  for (int i = 0; i < N; i++) {
    int sum = 0;
    if (i > 0) {
      sum += ldp[i - 1].first;
      if (ldp[i - 1].second + C + 1 < N)
        sum += rdp[ldp[i - 1].second + C + 1].first;
    } else
      sum = rdp[i + 1].first;
    if (sum < K)
      printf("%d\\n", i + 1);
  }
}