alexjercan/bugnet huggingface dataset:
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
long long n, k, c;
string s;
long long l[200100], r[200100];
vector<int> v;
int main() {
  cin >> n >> k >> c;
  cin >> s;
  long long sum = 0;
  for (int i = 0; i < s.size(); i++)
    if (s[i] == 'o') {
      sum++;
      v.push_back(i);
      i += c;
    }
  if (sum > k)
    return 0;
  if (s[0] == 'o')
    l[0] = 1;
  for (int i = 1; i < s.size(); i++) {
    if (i >= c + 1)
      l[i] = max(l[i - 1], l[i - c - 1] + (s[i] == 'o'));
    else
      l[i] = max(l[i - 1], (long long)(s[i] == 'o'));
  }
  for (int i = s.size() - 1; i >= 0; i--) {
    if (i + c + 1 < s.size())
      r[i] = max(r[i + 1], r[i + c + 1] + (s[i] == 'o'));
    else
      r[i] = max(r[i + 1], (long long)(s[i] == 'o'));
  }
  vector<int> ans;
  for (int i = 0; i < v.size(); i++) {
    if (v[i] == 0 && sum != +r[v[i] + 1])
      cout << (v[i] + 1) << endl;
    else if (v[i] == s.size() - 1 && sum != l[v[i] - 1])
      cout << v[i] + 1 << endl;
    else if (sum != l[v[i] - 1] + r[v[i] + 1])
      cout << (v[i] + 1) << endl;
  }
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
long long n, k, c;
string s;
long long l[100100], r[100100];
vector<int> v;
int main() {
  cin >> n >> k >> c;
  cin >> s;
  long long sum = 0;
  for (int i = 0; i < s.size(); i++)
    if (s[i] == 'o') {
      sum++;
      v.push_back(i);
      i += c;
    }
  if (sum > k)
    return 0;
  if (s[0] == 'o')
    l[0] = 1;
  for (int i = 1; i < s.size(); i++) {
    if (i >= c + 1)
      l[i] = max(l[i - 1], l[i - c - 1] + (s[i] == 'o'));
    else
      l[i] = max(l[i - 1], (long long)(s[i] == 'o'));
  }
  for (int i = s.size() - 1; i >= 0; i--) {
    if (i + c + 1 < s.size())
      r[i] = max(r[i + 1], r[i + c + 1] + (s[i] == 'o'));
    else
      r[i] = max(r[i + 1], (long long)(s[i] == 'o'));
  }
  vector<int> ans;
  for (int i = 0; i < v.size(); i++) {
    if (v[i] == 0 && sum != +r[v[i] + 1])
      cout << (v[i] + 1) << endl;
    else if (v[i] == s.size() - 1 && sum != l[v[i] - 1])
      cout << v[i] + 1 << endl;
    else if (sum != l[v[i] - 1] + r[v[i] + 1])
      cout << (v[i] + 1) << endl;
  }
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using u32 = uint32_t;
using u64 = uint64_t;
using s64 = int64_t;

int main() {
  u32 N, K, C;
  cin >> N >> K >> C;

  boost::dynamic_bitset<> days(N);

  for (u64 i = 0; i < N; i++) {
    char c;
    cin >> c;
    days[i] = (c == 'o');
  }

  vector<u64> L(K, N);
  for (u64 i = 0, l = 0; i < N && l < K;) {
    if (days[i]) {
      L[l] = i;
      i += C + 1;
      l++;
    } else {
      i++;
    }
  }

  vector<u64> R(K, N + 1);
  for (s64 i = N - 1, r = K - 1; i >= 0 && r >= 0;) {
    if (days[i]) {
      R[r] = i;
      i -= (C + 1);
      r--;
    } else {
      i--;
    }
  }

  for (u64 i = 0; i < K; i++) {
    // cout << L[i] << " " << R[i] << endl;
    if (L[i] == R[i]) {
      cout << L[i] + 1 << endl;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using u32 = uint32_t;
using u64 = uint64_t;

int main() {
  u32 N, K, C;
  cin >> N >> K >> C;

  boost::dynamic_bitset<> days(N);

  for (u64 i = 0; i < N; i++) {
    char c;
    cin >> c;
    days[i] = (c == 'o');
  }

  for (u64 i = 0; i < N; i++) {
    if (!days[i])
      continue;

    u64 wday = 0;

    for (u64 j = 0; j < N && wday < K;) {
      if (i != j && days[j]) {
        wday++;
        j += C + 1;
      } else {
        j++;
      }
    }

    if (wday < K && days[i])
      cout << i + 1 << endl;
  }

  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n; i >= 0; --i)
const int inf = 1e9 + 7;
const ll mod = 1e9 + 7;
const ll mod1 = 998244353;
const ll big = 1e18;
const double PI = 2 * asin(1);

int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<int> arr1, arr2;
  map<int, int> amap;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == 'o') {
      arr1.push_back(i);
      i += C;
    }
  }

  for (int i = S.size() - 1; i >= 0; --i) {
    if (S[i] == 'o') {
      arr2.push_back(i);
      i -= C;
    }
  }
  reverse(arr2.begin(), arr2.end());
  vector<int> ans;
  for (int i = 0; i < min(arr1.size(), arr2.size()); ++i) {
    if (arr1[i] == arr2[i])
      ans.push_back(arr1[i]);
  }
  if (ans.size() > K)
    return 0;
  for (int i = 0; i < ans.size(); ++i)
    cout << ans[i] + 1 << endl;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n; i >= 0; --i)
const int inf = 1e9 + 7;
const ll mod = 1e9 + 7;
const ll mod1 = 998244353;
const ll big = 1e18;
const double PI = 2 * asin(1);

int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<int> arr1(K), arr2(K);
  map<int, int> amap;
  int index = 0;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == 'o') {
      arr1[index] = i;
      index++;
      i += C;
    }
  }

  index = K - 1;
  for (int i = S.size() - 1; i >= 0; --i) {
    if (S[i] == 'o') {
      arr2[index] = i;
      index--;
      i -= C;
    }
  }
  vector<int> ans;
  return 0;
  for (int i = 0; i < min(arr1.size(), arr2.size()); ++i) {
    if (arr1[i] == arr2[i])
      ans.push_back(arr1[i]);
  }
  if (ans.size() > K)
    return 0;
  for (int i = 0; i < ans.size(); ++i)
    cout << ans[i] + 1 << endl;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

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

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

  vector<int> left(k), right(k);
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      left[count] = i + 1;
      count += 1;
      i += c;
      if (count == k)
        break;
    }
  }
  count = k - 1;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'o') {
      right[count] = i + 1;
      count -= 1;
      i -= c;
      if (count == -1)
        break;
    }
  }
  /*
  for(int i=0; i<k; i++) cout << left[i] << " ";
  cout << endl;
  for(int i=0; i<k; i++) cout << right[i] << " ";
  cout << endl;
  */
  for (int i = 0; i < k; i++) {
    if (left[i] == right[i])
      cout << left[i] << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

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

  vector<int> left(k), right(k);
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      left[count] = i + 1;
      count += 1;
      i += c;
      if (count == k)
        break;
    }
  }
  count = k - 1;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'o') {
      right[count] = i + 1;
      count -= 1;
      i -= c;
      if (count == k)
        break;
    }
  }
  /*
  for(int i=0; i<k; i++) cout << left[i] << " ";
  cout << endl;
  for(int i=0; i<k; i++) cout << right[i] << " ";
  cout << endl;
  */
  for (int i = 0; i < k; i++) {
    if (left[i] == right[i])
      cout << left[i] << endl;
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  vector<int> L(K);
  int idx = 0, c = 0;
  for (int i = 0; i < N; i++) {
    if (c > 0)
      c--;
    else {
      if (S.at(i) == 'o') {
        L.at(idx) = i;
        idx++;
        if (idx >= K) {
          break;
        }
        c = C;
      }
    }
  }

  vector<int> R(K);
  idx = K - 1;
  c = 0;
  for (int i = N - 1; i >= 0; i--) {
    if (c > 0)
      c--;
    else {
      if (S.at(i) == 'o') {
        R.at(idx) = i;
        idx--;
        if (idx < 0) {
          break;
        }
        c = C;
      }
    }
  }

  for (int i = 0; i < K; i++) {
    if (L.at(i) == R.at(i)) {
      cout << L.at(i) + 1 << endl;
    }
  }
}

Error: TLE

Fixed submission:

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

bool can_assign(string s, int k, int c, int from) {
  for (int i = 0; i < s.length(); i++) {
    if (s.at(i) == 'o') {
      for (int j = 0; j <= c && i + j < s.length(); j++) {
        s.at(i + j) = 'x';
      }
      i += c;
      k--;
    }
  }
  if (k > 0)
    return false;
  else
    return true;
}

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

  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'o') {
      string S0 = S;
      S0.at(i) = 'x';
      if (!can_assign(S0, K, C, 0)) {
        cout << i + 1 << endl;
      }
    }
  }
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))

typedef long long ll;

using namespace std;

int N, K, C;
char input[200000 + 5];

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

  scanf("%d %d %d", &N, &K, &C);
  scanf("%s", input);

  int last = -C - 1;

  vector<int> min_idx;
  vector<int> max_idx;

  for (int i = 0; i < N; ++i) {
    if (input[i] == 'o' && i >= last + C + 1) {
      min_idx.push_back(i + 1);
      last = i;
      if (min_idx.size() == K + 1)
        break;
    }
  }

  last = N - 1 + C + 1;

  for (int i = N - 1; i >= 0; --i) {
    if (input[i] == 'o' && i <= last - C - 1) {
      max_idx.push_back(i + 1);
      last = i;
      if (max_idx.size() == K + 1)
        break;
    }
  }

  sort(max_idx.begin(), max_idx.end());

  if (min_idx.size() == K && max_idx.size() == K) {
    for (int i = 0; i < min_idx.size(); ++i) {
      auto it = lower_bound(max_idx.begin(), max_idx.end(), min_idx[i]);
      if (*it == min_idx[i])
        printf("%d\\n", min_idx[i]);
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))

typedef long long ll;

using namespace std;

int N, K, C;
char input[200000 + 5];

bool chk(int idx) {
  input[idx - 1] = 'x';
  int last = -C - 1;
  int sz = 0;

  for (int i = 0; i < N; ++i) {
    if (input[i] == 'o' && i >= last + C + 1) {
      last = i;
      sz++;
      if (sz == K) {
        input[idx - 1] = 'o';
        return false;
      }
    }
  }

  input[idx - 1] = 'o';
  return true;
}

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

  scanf("%d %d %d", &N, &K, &C);
  scanf("%s", input);

  int last = -C - 1;

  vector<int> min_idx;
  vector<int> max_idx;

  for (int i = 0; i < N; ++i) {
    if (input[i] == 'o' && i >= last + C + 1) {
      min_idx.push_back(i + 1);
      last = i;
      if (min_idx.size() == K)
        break;
    }
  }

  last = N - 1 + C + 1;

  for (int i = N - 1; i >= 0; --i) {
    if (input[i] == 'o' && i <= last - C - 1) {
      max_idx.push_back(i + 1);
      last = i;
      if (max_idx.size() == K)
        break;
    }
  }

  sort(max_idx.begin(), max_idx.end());

  if (min_idx.size() == K && max_idx.size() == K) {
    for (int i = 0; i < min_idx.size(); ++i) {
      auto it = lower_bound(max_idx.begin(), max_idx.end(), min_idx[i]);
      if (*it == min_idx[i] && chk(min_idx[i]))
        printf("%d\\n", min_idx[i]);
    }
  }

  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int n, k, c;
  cin >> n >> k >> c;

  string s;
  cin >> s;

  vector<bool> ans(n, false); // 働かなくてもいい日はtrue
  vector<int> work;
  int prev = -c - 1;

  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      if (prev + c < i && work.size() < k) {
        work.push_back(i);
        prev = i;
      } else {
        ans[i] = true;
      }
    }
  }

  int idx = k - 1;
  prev = n + c + 1;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'x')
      continue;
    if (i > work[idx]) {
      if (i + c < prev) {
        ans[work[idx]] = true;
        prev = i;
        idx--;
      }
    } else if (i == work[idx]) {
      idx--;
      prev = i;
    }

    if (idx == -1)
      break;
  }

  for (int i = 0; i < n; i++) {
    if (s[i] == 'o' && ans[i] == false) {
      cout << i + 1 << '\\n';
    }
  }

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int n, k, c;
  cin >> n >> k >> c;

  string s;
  cin >> s;

  vector<bool> ans(n, false); // 働かなくてもいい日はtrue
  vector<int> work;
  int prev = -c - 1;

  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      if (prev + c < i && work.size() < k) {
        work.push_back(i);
        prev = i;
      } else {
        ans[i] = true;
      }
    }
  }

  int idx = k - 1;
  prev = n + c + 1;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'x')
      continue;
    if (i > work[idx]) {
      if (i + c < prev) {
        ans[work[idx]] = true;
        prev = i;
        idx--;
      }
    } else if (i == work[idx]) {
      idx--;
      prev = i;
    }
  }

  for (int i = 0; i < n; i++) {
    if (s[i] == 'o' && ans[i] == false) {
      cout << i + 1 << '\\n';
    }
  }

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

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

int main() {

  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;

  vector<int> ans1, ans2;

  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      ans1.push_back(i);
      i += c;
    }
  }

  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'o') {
      ans2.push_back(i);
      i -= c;
    }
  }

  if (ans1.size() == k) {
    for (auto n : ans1) {
      if (binary_search(ans2.rbegin(), ans2.rend(), n)) {
        cout << n + 1 << endl;
      }
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {

  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;

  vector<int> ans1, ans2;

  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      ans1.push_back(i);
      i += c;
    }
  }

  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'o') {
      ans2.push_back(i);
      i -= c;
    }
  }

  if (ans1.size() == k) {
    for (auto n : ans1) {
      if (find(ans2.begin(), ans2.end(), n) != ans2.end()) {
        cout << n + 1 << endl;
      }
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
vector<int> f, b;
int n, k, c;
string s;
int main() {
  cin >> n >> k >> c >> s;
  int last = -1e9;
  for (int i = 1; i <= n; i++) {
    if (s[i - 1] == 'o' && last + c < i) {
      last = i;
      f.push_back(i);
    }
    if (f.size() == k)
      break;
  }
  int stock = 1e9;
  for (int i = n; i >= 1; i--) {
    if (s[i - 1] == 'o' && stock >= c) {
      b.push_back(i);
      stock = 0;
    } else
      stock++;
    if (b.size() == k)
      break;
  }
  reverse(b.begin(), b.end());
  for (int i = 0; i < k; i++)
    if (b[i] == f[i])
      cout << f[i] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int n, k, c, cnt, f[300001], b[300001];
string s;
int main() {
  cin >> n >> k >> c >> s;
  for (int i = 1; i <= n; i++)
    if (s[i - 1] == 'o') {
      cnt++;
      f[i] = cnt;
      for (int l = i + 1; l <= i + c, l <= n; l++)
        f[l] = cnt;
      i = min(n, i + c);
    } else
      f[i] = cnt;

  cnt = 0;
  for (int i = n; i >= 1; i--)
    if (s[i - 1] == 'o') {
      cnt++;
      b[i] = cnt;
      for (int l = i - 1; l >= i - c, l >= 1; l--)
        b[l] = cnt;
      i = max(1, i - c);
    } else
      b[i] = cnt;
  for (int i = 1; i <= n; i++)
    if (s[i - 1] == 'o')
      if (f[i - 1] + b[i + 1] + 1 == k)
        cout << i << endl;
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

/*
 * Author:  heyuhhh
 * Created Time:  2020/5/13 17:07:47
 */
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
#define dbg(args...)                                                           \\
  do {                                                                         \\
    cout << #args << " -> ";                                                   \\
    err(args);                                                                 \\
  } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args> void err(T a, Args... args) {
  std::cout << a << ' ';
  err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &...args) {
  for (auto &v : arg)
    std::cout << v << ' ';
  err(args...);
}
#else
#define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
// head
const int N = 2e5 + 5;

int n, k, c;
char s[N];
int nxt[N], last[N];

void run() {
  cin >> n >> k >> c;
  cin >> (s + 1);
  int t = 0;
  int now;
  for (int i = 1, j; i <= n; i = j) {
    now = i;
    j = i + c + 1;
    while (j <= n && s[j] == 'x')
      ++j;
    if (j <= n) {
      nxt[i] = j;
      last[j] = i;
      ++t;
    }
  }
  ++t;
  if (t != k)
    return;
  vector<int> pre(n + 2);
  for (int i = 1; i <= n + 1; i++) {
    pre[i] = pre[i - 1] + (s[i] == 'o');
  }
  vector<int> ans;
  int rb = n + 1;
  for (int i = now; i; i = last[i]) {
    if (rb == i || pre[rb] - pre[i] == 0) {
      ans.push_back(i);
    }
    for (int j = min(rb, i + c); j >= i; j--) {
      if (s[j] == 'o') {
        rb = j - c - 1;
        break;
      }
    }
  }
  sort(all(ans));
  for (auto it : ans)
    cout << it << '\\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(20);
  run();
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int n, k, c;
string s;
int l[100005];
int r[100005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> c >> s;
  int cnt = 1;
  for (int i = 0; i < n && cnt <= k; i++) {
    if (s[i] == 'o') {
      l[i] = cnt++;
      i += c;
    } else {
      continue;
    }
  }
  cnt--;
  for (int i = n - 1; i >= 0 && cnt >= 1; i--) {
    if (s[i] == 'o') {
      r[i] = cnt--;
      i -= c;
    } else {
      continue;
    }
  }
  for (int i = 0; i < n; i++) {
    if (l[i] != 0 && r[i] != 0 && l[i] == r[i]) {
      cout << i + 1 << endl;
    }
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(), v.end()
typedef long long ll;

int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<int> saki_bataraki(K);
  vector<int> ato_bataraki(K);
  int count = C;
  int next = 0;
  rep(i, N) {
    if (next == K) {
      break;
    } else if (count < C || S[i] == 'x') {
      count++;
    } else {
      saki_bataraki[next] = i;
      count = 0;
      next++;
    }
  }
  count = C;
  next = K - 1;
  for (int i = N - 1; i >= 0; i--) {
    if (next == -1) {
      break;
    } else if (count < C || S[i] == 'x') {
      count++;
    } else {
      ato_bataraki[next] = i;
      count = 0;
      next--;
    }
  }
  vector<int> ans(0);
  rep(i, K) {
    if (saki_bataraki[i] == ato_bataraki[i]) {
      ans.push_back(saki_bataraki[i] + 1);
    }
  }
  rep(i, ans.size()) cout << ans[i] << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(), v.end()
typedef long long ll;

int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<int> saki_bataraki(K);
  vector<int> ato_bataraki(K);
  int count = C;
  int next = 0;
  rep(i, N) {
    if (next == K) {
      break;
    } else if (count < C || S[i] == 'x') {
      count++;
    } else {
      saki_bataraki[next] = i;
      count = 0;
      next++;
    }
  }
  count = C;
  next = K - 1;
  for (int i = N - 1; i >= 0; i--) {
    if (next == K) {
      break;
    } else if (count < C || S[i] == 'x') {
      count++;
    } else {
      ato_bataraki[next] = i;
      count = 0;
      next--;
    }
  }
  rep(i, K) {
    if (saki_bataraki[i] == ato_bataraki[i]) {
      cout << saki_bataraki[i] + 1 << endl;
    }
  }
}