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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#define cs                                                                     \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define rep(i, b) for (int i = 0; i < (int)(b); i++)
#define Rep(i, n) for (int i = 1; i < (int)(n); i++)
#define repp(i, a, b) for (int i = a; i <= (int)(b); i++)
#define Repp(i, a, b) for (int i = a; i >= (int)(b); i--)
using namespace std;

int main() {
  cs;
  int n, k, c, t = 0, it = 0;
  string s;
  cin >> n >> k >> c >> s;
  vector<int> v(k);
  while (t < k) {
    if (s[it] == 'o') {
      v[t] = it;
      t++;
      it += c + 1;
    } else
      it++;
  }
  t = k - 1;
  it = n - 1;
  while (t >= 0) {
    if (s[it] == 'o') {
      if (v[t] != it)
        v[t] = -1;
      t--;
      it -= c + 1;
    } else
      it--;
  }

  rep(i, k) if (v[i] != -1) cout << v[i] + 1 << '\\n';
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <vector>
#define cs                                                                     \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define rep(i, b) for (int i = 0; i < (int)(b); i++)
#define Rep(i, n) for (int i = 1; i < (int)(n); i++)
#define repp(i, a, b) for (int i = a; i <= (int)(b); i++)
#define Repp(i, a, b) for (int i = a; i >= (int)(b); i--)
typedef long long ll;
typedef long double ld;
using namespace std;
int n, k, c;
string s;
bool f(int x, int p) {
  int t = p, g = x + 1;
  while (g < n) {
    if (s[g] == 'o') {
      t++;
      g += c + 1;
      if (t == k)
        return 1;
    } else
      g++;
  }
  return 0;
}
int main() {
  cs;
  int t = 0, it = 0;
  cin >> n >> k >> c >> s;
  vector<int> v(k);
  while (t != k) {
    if (s[it] == 'o') {
      v[t] = it;
      t++;
      it += c + 1;
    } else
      it++;
  }
  rep(i, k) if (f(v[i], i)) v[i] = -1;

  for (auto i : v)
    if (i != -1)
      cout << i + 1 << '\\n';
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N, K, C;
  string S;
  cin >> N >> K >> C;
  cin >> S;
  vector<int> front, back;
  for (int i = 0; i < N; i++) {
    if (front.size() == K)
      break;
    if (S[i] == 'o') {
      front.push_back(i);
      i += C;
    }
  }
  for (int i = N - 1; i >= 0; i--) {
    if (back.size() == K)
      break;
    if (S[i] == 'o') {
      back.push_back(i);
      i -= C;
    }
  }
  int MAX = min(front.size(), back.size());
  if (MAX <= K) {
    for (int i = 0; i < MAX; i++) {
      if (front[i] == back[back.size() - i - 1]) {
        cout << front[i] + 1 << endl;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N, K, C;
  string S;
  cin >> N >> K >> C;
  cin >> S;
  vector<int> front, back;
  for (int i = 0; i < N; i++) {
    if (front.size() == K)
      break;
    if (S[i] == 'o') {
      front.push_back(i);
      i += C;
    }
  }
  for (int i = N - 1; i >= 0; i--) {
    if (back.size() == K)
      break;
    if (S[i] == 'o') {
      back.insert(back.begin(), i);
      i -= C;
    }
  }
  int MAX = min(front.size(), back.size());
  if (MAX <= K) {
    for (int i = 0; i < MAX; i++) {
      if (front[i] == back[i]) {
        cout << front[i] + 1 << endl;
      }
    }
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<int> L(N, 0), R(N, 0);
  int cur = 1;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'o') {
      L[i] = cur++;
      i += C;
    }
    if (cur == K + 1)
      break;
  }
  cur--;
  for (int i = N - 1; i > -1; i--) {
    if (S[i] == 'o') {
      R[i] = cur--;
      i -= C;
    }
    if (cur == -1)
      break;
  }
  for (int i = 0; i < N; i++) {
    if (L[i] != 0 && L[i] == R[i])
      cout << i + 1 << '\\n';
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int N, K, C;
string S;
vector<int64_t> cnt;

/* bool f(int day, int work) { */
/*   if (day > N - 1) { */
/*     return work == K; */
/*   } */

/*   int64_t res = 0; */
/*   res += f(day + 1, work); */
/*   if (S[day] == 'o') { */
/*     res += f(day + C + 1, work + 1); */
/*   } */
/*   return res; */
/* } */

int64_t f(int day, int work) {
  if (day > N - 1) {
    return work == K ? 1 : 0;
  }

  int64_t res = 0;
  res += f(day + 1, work);
  if (S[day] == 'o') {
    int64_t tmp = -1;
    tmp = f(day + C + 1, work + 1);
    cnt[day] += tmp;
    /* res += f(day + C + 1, work + 1); */
    res += tmp;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K >> C;
  cin >> S;
  cnt.resize(N + 1, 0);
  int64_t r = f(0, 0);
  for (int i = 0; i < (int)cnt.size(); i++) {
    if (cnt[i] == r) {
      cout << i + 1 << '\\n';
    }
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
int L[200001];
int R[200001];

int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  memset(L, -1, sizeof(L));
  memset(R, INT_MAX / 2, sizeof(R));
  int cur = 0;
  for (int i = 0; cur < K && i < N; i++) {
    if (S[i] == 'x')
      continue;
    else {
      L[cur] = i;
      cur++;
      i += C;
    }
  }
  cur = K - 1;
  for (int i = N - 1; cur >= 0 && i >= 0; i--) {
    if (S[i] == 'x')
      continue;
    else {
      R[cur] = i;
      cur--;
      i -= C;
    }
  }
  for (int i = 0; i < K; i++) {
    if (L[i] == R[i]) {
      cout << L[i] + 1 << endl;
    }
  }
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
int L[200001];
int R[200001];

int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  memset(L, -1, sizeof(L));
  memset(R, INT_MAX / 2, sizeof(R));
  int cur = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'x')
      continue;
    else {
      L[cur] = i;
      cur++;
      i += C;
    }
  }
  cur = K - 1;
  for (int i = N - 1; i >= 0; i--) {
    if (S[i] == 'x')
      continue;
    else {
      R[cur] = i;
      cur--;
      i -= C;
    }
  }
  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: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

const int MAXS = 300010;
char str[MAXS];

int main() {
  int N;
  int K;
  int C;

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

  vector<int> best(N);
  vector<int> slack(N, K);

  ++C;
  for (int i = 0; i < N; ++i) {
    if (i) {
      best[i] = max(best[i], best[i - 1]);
    }

    if (str[i] == 'o') {
      int preMax = 0;

      if (i - C >= 0) {
        preMax = best[i - C];
      }

      best[i] = max(best[i], preMax + 1);
    }
  }

  for (int i = N - 1; i >= 0; --i) {
    if (str[i] == 'o') {
      if (i - C >= 0) {
        slack[i - C] = min(slack[i - C], slack[i] - 1);
      }
    }

    if (i) {
      slack[i - 1] = min(slack[i - 1], slack[i]);
    }
  }

  // for (int i = 0; i < N; ++i) {
  //     cout << best[i] << " ";
  // }

  // cout << endl;

  // for (int i = 0; i < N; ++i) {
  //     cout << slack[i] << " ";
  // }

  // cout << endl;

  unordered_map<int, int> critCount;

  for (int i = 0; i < N; ++i) {
    if (slack[i] == best[i] && str[i] == 'o') {
      ++critCount[best[i]];
    }
  }

  for (int i = 0; i < N; ++i) {
    if (slack[i] == best[i] && str[i] == 'o' && critCount[best[i]] == 1) {
      cout << i + 1 << endl;
      ;
    }
  }

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

const int MAXS = 100010;
char str[MAXS];

int main() {
  int N;
  int K;
  int C;

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

  vector<int> best(N);
  vector<int> slack(N, K);

  ++C;
  for (int i = 0; i < N; ++i) {
    if (i) {
      best[i] = max(best[i], best[i - 1]);
    }

    if (str[i] == 'o') {
      int preMax = 0;

      if (i - C >= 0) {
        preMax = best[i - C];
      }

      best[i] = max(best[i], preMax + 1);
    }
  }

  for (int i = N - 1; i >= 0; --i) {
    if (str[i] == 'o') {
      if (i - C >= 0) {
        slack[i - C] = min(slack[i - C], slack[i] - 1);
      }
    }

    if (i) {
      slack[i - 1] = min(slack[i - 1], slack[i]);
    }
  }

  // for (int i = 0; i < N; ++i) {
  //     cout << best[i] << " ";
  // }

  // cout << endl;

  // for (int i = 0; i < N; ++i) {
  //     cout << slack[i] << " ";
  // }

  // cout << endl;

  unordered_map<int, int> critCount;

  for (int i = 0; i < N; ++i) {
    if (slack[i] == best[i] && str[i] == 'o') {
      ++critCount[best[i]];
    }
  }

  for (int i = 0; i < N; ++i) {
    if (slack[i] == best[i] && str[i] == 'o' && critCount[best[i]] == 1) {
      cout << i + 1 << endl;
      ;
    }
  }

  return 0;
}
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;
  vector<int> L(k), R(k);
  int i = 0;
  int num = 0;
  while (i < n) {
    if (s[i] == 'o') {
      if (num > k)
        return 0;
      L[num++] = i + 1;
      i += c;
    }
    i++;
  }
  i = n - 1;
  num = k - 1;
  while (i >= 0) {
    if (s[i] == 'o') {
      if (num < 0)
        return 0;
      R[num--] = i + 1;
      i -= c;
    }

    i--;
  }

  for (int j = 0; j < k; j++) {
    if (R[j] == L[j])
      cout << R[j] << endl;
  }

  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;
  vector<int> L(k), R(k);
  int i = 0;
  int num = 0;
  while (i < n) {
    if (s[i] == 'o') {
      L[num++] = i + 1;
      i += c;
    }
    i++;
  }
  i = n - 1;
  num = k - 1;
  while (i >= 0) {
    if (s[i] == 'o') {
      R[num--] = i + 1;
      i -= c;
    }

    i--;
  }

  for (int j = 0; j < k; j++) {
    if (R[j] == L[j])
      cout << R[j] << endl;
  }

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

#include <bits/stdc++.h>
#define FOR(i, a, n) for (int(i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for (int(i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for (int(i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  auto getPos = [&]() {
    vector<int> res;
    for (int i = 0; i < n && res.size() < k;) {
      if (s[i] == 'o') {
        res.push_back(i);
        i += c + 1;
      } else
        i++;
    }
    return res;
  };
  vector<int> l, r;
  l = getPos();
  reverse(all(s));
  r = getPos();
  if (l.size() != k || r.size() != k)
    return 0;
  REP(i, r.size()) r[i] = n - 1 - r[i];
  reverse(all(r));
  REP(i, k) {
    if (l[i] == r[i])
      cout << l[i] + 1 << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define FOR(i, a, n) for (int(i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for (int(i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for (int(i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int n, k, c;
string s;
int num[200005];
int dfs(int x, int d) {
  if (d == k) {
    return 1;
  } else if (x > n)
    return 0;
  int X = 0;
  FORe(i, x + 1, n) {
    if (s[i - 1] == 'o') {
      int a = dfs(i + c, d + 1);
      num[i] += a;
      X += a;
    }
  }
  return X;
}

int main() {
  cin >> n >> k >> c >> s;
  int count = dfs(0, 0);
  // cout << count << endl;
  FORe(i, 1, n) {
    // cout << num[i] << endl;
    if (count == num[i])
      cout << i << endl;
  }

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

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size()
#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define forn(i, n) for (int i = 1; i <= n; i++)
#define ford(i, n) for (int i = n; i >= 0; i--)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define foreach(itr, c)                                                        \\
  for (__typeof((c).begin(), (c).end()) itr = c.begin(); itr != c.end(); itr++)
#define fill(a, b) memset(a, b, sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
int main() {
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  int cnt = 0;
  int earliest[k], latest[k];
  rep(i, n) {
    if (s[i] == 'o') {
      earliest[cnt] = i;
      cnt++;
      i += c;
    }
    if (cnt == k) {
      break;
    }
  }
  cnt--;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'o') {
      latest[cnt] = i;
      cnt--;
      i -= c;
    }
    if (cnt == -1) {
      break;
    }
  }
  vi ans;
  rep(i, k) {
    if (earliest[i] == latest[i]) {
      ans.pb(earliest[i] + 1);
    }
  }
  rep(i, ans.size()) { cout << ans[i] << endl; }
  re 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size()
#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define forn(i, n) for (int i = 1; i <= n; i++)
#define ford(i, n) for (int i = n; i >= 0; i--)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define foreach(itr, c)                                                        \\
  for (__typeof((c).begin(), (c).end()) itr = c.begin(); itr != c.end(); itr++)
#define fill(a, b) memset(a, b, sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
int main() {
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  int cnt = 0;
  int earliest[k], latest[k];
  rep(i, n) {
    if (s[i] == 'o') {
      earliest[cnt] = i;
      cnt++;
      i += c;
    }
  }
  cnt--;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'o') {
      latest[cnt] = i;
      cnt--;
      i -= c;
    }
  }
  vi ans;
  rep(i, k) {
    if (earliest[i] == latest[i]) {
      ans.pb(earliest[i] + 1);
    }
  }
  rep(i, ans.size()) { cout << ans[i] << endl; }
  re 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 7;

int pre[N];
int n, m, k;
string s;
vector<int> ans;

int dp[N];

int solve(int i) {
  if (i >= n)
    return 0;
  if (dp[i] != -1)
    return dp[i];
  if (s[i] == 'o') {
    return dp[i] = 1 + solve(i + k + 1);
  }
  return dp[i] = solve(i + 1);
}

int main() {
  memset(dp, -1, sizeof dp);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  // freopen("in.in" , "r" , stdin) ;

  cin >> n >> m >> k;
  cin >> s;

  for (int i = 0; i < n; i++) {
    solve(i);
  }

  int l = -1, sum = 0;
  for (int i = 0; i < n; i++) {
    pre[i] = sum;
    if (i <= l)
      continue;
    if (s[i] == 'o') {
      sum++;
      l = i + k;
    }
    pre[i] = sum;
  }
  int r = n + N;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'o') {
      int leftix = min(i - 1, r - k - 1);
      int right = solve(i + 1);
      int left = (leftix < 0 ? 0 : pre[leftix]);
      if (right + left < m) {
        ans.push_back(i + 1);
      }
      if (solve(i) > solve(r))
        r = i;
    }
  }
  reverse(ans.begin(), ans.end());
  for (auto u : ans) {
    cout << u << "\\n";
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 7;

int pre[N];
int n, m, k;
string s;
vector<int> ans;

int dp[N];

int solve(int i) {
  if (i >= n)
    return 0;
  if (dp[i] != -1)
    return dp[i];
  if (s[i] == 'o') {
    return 1 + solve(i + k + 1);
  }
  return dp[i] = solve(i + 1);
}

int main() {
  memset(dp, -1, sizeof dp);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  // freopen("in.in" , "r" , stdin) ;

  cin >> n >> m >> k;
  cin >> s;

  for (int i = 0; i < n; i++) {
    solve(i);
  }

  int l = -1, sum = 0;
  for (int i = 0; i < n; i++) {
    pre[i] = sum;
    if (i <= l)
      continue;
    if (s[i] == 'o') {
      sum++;
      l = i + k;
    }
    pre[i] = sum;
  }
  int r = n + N;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'o') {
      int leftix = min(i - 1, r - k - 1);
      int right = solve(i + 1);
      int left = (leftix < 0 ? 0 : pre[leftix]);
      if (right + left < m) {
        ans.push_back(i + 1);
      }
      if (solve(i) > solve(r))
        r = i;
    }
  }
  reverse(ans.begin(), ans.end());
  for (auto u : ans) {
    cout << u << "\\n";
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i, n, k) for (int i = (n); i < (k); i++)
#define ALL(a) (a).begin(), (a).end()
ll ans = 0;
ll n, k, c;
vector<int> calc(string s) {
  vector<int> day;
  int interval = c + 1;
  For(i, 0, n) {
    if (s[i] == 'x') {
      interval++;
    } else {
      if (interval < c) {
        interval++;
      } else {
        day.push_back(i + 1);
        interval = 0;
      }
    }
  }
  return day;
}
void Main() {
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vector<int> dp = calc(s);
  if (dp.size() > k)
    return;
  reverse(ALL(s));
  vector<int> pd = calc(s);
  For(i, 0, k) { pd[i] = n + 1 - pd[i]; }
  reverse(ALL(pd));
  For(i, 0, k) {
    if (pd[i] == dp[i])
      cout << dp[i] << endl;
  }
}
int main() {
  Main();
  /*
  東方風神録は神が出てくるので当然神ゲー
  */
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i, n, k) for (int i = (n); i < (k); i++)
#define ALL(a) (a).begin(), (a).end()
ll ans = 0;
ll n, k, c;
bool calc(int x, string s) {
  s[x] = 'x';
  vector<int> day(n + 1, 0);
  int interval = c + 1;
  For(i, 0, n) {
    if (s[i] == 'x') {
      day[i + 1] = day[i];
      interval++;
    } else {
      if (interval < c) {
        day[i + 1] = day[i];
        interval++;
      } else {
        day[i + 1] = day[i] + 1;
        interval = 0;
      }
    }
  }
  /*cout<<x+1<<" : ";
  For(i,0,n) {
      cout<<day[i+1]<<" ";
  }
  cout<<endl;*/
  if (day[n] == k)
    return false;
  else
    return true;
}
void Main() {
  cin >> n >> k >> c;
  string s;
  cin >> s;
  if (c == 0) {
    ll cnt = 0;
    For(i, 0, n) cnt += (s[i] == 'o');
    if (cnt == k) {
      For(i, 0, n) {
        if (s[i] == 'o') {
          cout << i + 1 << endl;
        }
      }
    }
    return;
  }
  vector<int> day(n + 1, 0);
  int interval = c + 1;
  For(i, 0, n) {
    if (s[i] == 'x') {
      day[i + 1] = day[i];
      interval++;
    } else {
      if (interval < c) {
        day[i + 1] = day[i];
        interval++;
      } else {
        day[i + 1] = day[i] + 1;
        interval = 0;
      }
    }
  }
  if (day[n] > k)
    return;
  vector<int> kouho;
  /*For(i,0,n) {
      cout<<day[i+1]<<" ";
  }
  cout<<endl;*/
  For(i, 0, n) {
    if (day[i + 1] > day[i])
      kouho.push_back(i);
  }
  for (auto i : kouho) {
    if (calc(i, s))
      cout << i + 1 << endl;
  }
}
int main() {
  Main();
  /*
  東方風神録は神が出てくるので当然神ゲー
  */
  return 0;
}
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;
  cin >> S;

  int before[N + 2];
  int after[N + 2];
  for (int i = 0; i < N + 2; i++) {
    before[i] = 0;
    after[i] = 0;
  }
  for (int i = 1; i < N + 1; i++) {
    if (S[i - 1] == 'o') {
      before[i] += before[i - 1] + 1;
      for (int j = i; i < j + C && i < N + 1; i++) {
        before[i + 1] = before[i];
      }
      // cout << i << endl;
    } else {
      before[i] = before[i - 1];
    }
  }
  for (int i = N; i > 0; i--) {
    if (S[i - 1] == 'o') {
      after[i] += after[i + 1] + 1;
      for (int j = i; i > j - C && i > 0; i--) {
        after[i - 1] = after[i];
      }
    } else {
      after[i] = after[i + 1];
    }
  }
  for (int i = 1; i < N + 1; i++) {
    // cout << before[i-1] << " " << after[i+1] << " " << i << endl;
    if (before[i - 1] + after[i + 1] < K) {
      cout << i << endl;
    }
  }
}


Error: 0

Fixed submission:

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

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

  int before[N + 2];
  int after[N + 2];
  for (int i = 0; i < N + 2; i++) {
    before[i] = 0;
    after[i] = 0;
  }
  for (int i = 1; i < N + 1; i++) {
    if (S[i - 1] == 'o') {
      before[i] += before[i - 1] + 1;
      for (int j = i; i < j + C; i++) {
        before[i + 1] = before[i];
      }
      // cout << i << endl;
    } else {
      before[i] = before[i - 1];
    }
  }
  for (int i = N; i > 0; i--) {
    if (S[i - 1] == 'o') {
      after[i] += after[i + 1] + 1;
      for (int j = i; i > j - C; i--) {
        after[i - 1] = after[i];
      }
    } else {
      after[i] = after[i + 1];
    }
  }
  for (int i = 1; i < N + 1; i++) {
    // cout << before[i-1] << " " << after[i+1] << " " << i << endl;
    if (before[i - 1] + after[i + 1] < K) {
      cout << i << endl;
    }
  }
}