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

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()

typedef long long lint;

using namespace std;

int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<int> l(K, 0), r(K, 0);
  REP(i, K) {
    static int j = 0;
    while (S[j] == 'x')
      j++;
    l[i] = j;
    j += C + 1;
  }
  for (int i = K - 1; i >= 0; i--) {
    static int j = N - 1;
    while (S[j] == 'x')
      j--;
    r[i] = j;
    j -= C + 1;
  }
  // for(auto e:l)cerr<<(int)e<<" ";
  // cerr<<endl;
  // for(auto e:r)cerr<<(int)e<<" ";
  // cerr<<endl;
  REP(i, K) if (l[i] == r[i]) cout << l[i] + 1 << endl;
  return 0;
}


Error: 0

Fixed submission:

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()

typedef long long lint;

using namespace std;

int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<int> l(K, 0), r(K, 0);
  REP(i, K) {
    static int j = 0;
    while (S[j] == 'x')
      j++;
    l[i] = j;
    j += K;
  }
  for (int i = K - 1; i >= 0; i--) {
    static int j = N - 1;
    while (S[j] == 'x')
      j--;
    r[i] = j;
    j -= K;
  }
  // for(auto e:l)cerr<<(int)e<<" ";
  // cerr<<endl;
  // for(auto e:r)cerr<<(int)e<<" ";
  // cerr<<endl;
  REP(i, K) if (l[i] == r[i]) cout << l[i] + 1 << endl;
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;

int main(void) {

  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<int> SMAP(N, 0);
  vector<int> SMAP2(N, 0);
  int cnt = K;
  for (int i = N - 1; i >= 0; i--) {
    if (S[i] == 'o') {
      SMAP[i] = cnt;
      i -= C;
      cnt--;
    }
    if (cnt <= 0)
      break;
  }
  /*
  for(int i = 0; i < N; i++){
          cout<<SMAP[i]<<endl;
  }
  cout<<"\\n"<<endl;
  */
  cnt = 1;
  for (int i = 0; i < N; ++i) {
    if (S[i] == 'o') {
      if (SMAP[i] == cnt)
        cout << i + 1 << endl;
      SMAP2[i] = cnt;
      i += C;
      cnt++;
    }
    if (cnt > K)
      break;
  }
  /*
  for(int i = 0; i < N; i++){
          cout<<SMAP2[i]<<endl;
  }
  */
  /*
  for (int i = 0; i < N; ++i) {
      if(SMAP[i]==2) cout<<i+1<<endl;
  }
  cout<<endl;
      */

  return 0;
}


Error: -11

Fixed submission:

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

bool func(string s, int not_work_day);
int n, k, c;
int sup_work = 1;
int dp[max];
int main(void) {
  cin >> n >> k >> c;
  for (int i = 0; i < n; i++) {
    dp[i] = 0;
  }
  string s;
  cin >> s;

  for (int i = 1; i < n; i++) {
    if (s[i] == 'o') {
      dp[i] = dp[i - 1] + 1;
      for (int j = i + 1; j <= i + c; j++) {
        dp[j] = dp[j - 1];
      }
      i += c;
    } else
      dp[i] = dp[i - 1];
  }
  int www;
  for (int i = 1; i < n + 1; i++) {
    if (s[i - 1] == 'x')
      www = 0;
    else {
      if (func(s, i) == true)
        www = 0;
      else {
        cout << i << endl;
        i += c;
      }
    }
  }
  return 0;
}

bool func(string s, int not_work_day) {
  int re = 0;
  int i;
  int kk = k - dp[not_work_day];
  for (int j = not_work_day + 1; j < n + 1; j++) {
    if (j == not_work_day)
      j++;
    if (s[i - 1] == 'o') {
      // work!!;
      kk--;
      i += c;
      if (kk == 0) {
        return true;
      }
    }
  }
  return false;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
string S;
long long K, C;
vector<int> dp, cnt, can;
bool dfs(int ind, int cnt1) {
  if (dp[ind] != 0) {
    if (dp[ind] == cnt1)
      return true;
    return false;
  }
  auto ite = upper_bound(can.begin(), can.end(), can[ind] + C);
  if (ite == can.end()) {
    if (cnt1 == K) {
      dp[ind] = cnt1;
      cnt[cnt1]++;
      return true;
    }
    return false;
  }
  int ind2 = ite - can.begin();
  bool flag = dfs(ind2, cnt1 + 1);
  if (flag) {
    dp[ind] = cnt1;
    cnt[cnt1]++;
    return true;
  }
  return false;
}
int main() {
  long long N;
  cin >> N >> K >> C;
  cin >> S;
  can.resize(0);
  for (int i = 0; i < N; i++) {
    if (S[i] == 'o')
      can.push_back(i + 1);
  }
  int size = can.size();
  dp.resize(size, 0);
  cnt.resize(K + 1, 0);
  dfs(0, 1);
  int flag = 0;
  for (int i = 0; i < size; i++) {
    if (dp[i] == K)
      flag = 1;
    if (dp[i] > K) {
      cout << endl;
      return 0;
    }
  }
  if (flag == 0) {
    cout << endl;
    return 0;
  }
  for (int i = 0; i < size; i++) {
    if (dp[i] != 0)
      continue;
    int temp;
    if (can[i] - C - 1 < can[0])
      temp = 1;
    else {
      int inde =
          upper_bound(can.begin(), can.end(), can[i] - C - 1) - can.begin() - 1;
      if (inde >= 0 && inde != i)
        temp = dp[inde] + 1;
      else
        continue;
    }
    dfs(i, temp);
  }
  for (int i = 0; i < size; i++) {
    if (cnt[dp[i]] == 1)
      cout << can[i] << endl;
  }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
long long C, K;
bool dfs(vector<int> &cnt, vector<int> can, int ind1, int cnt1,
         vector<int> &dp) {
  if (dp[ind1] != 0)
    return true;
  auto ite = upper_bound(can.begin(), can.end(), can[ind1] + C);
  if (ite == can.end()) {
    if (cnt1 >= K) {
      dp[ind1] = cnt1;
      if (cnt1 == K)
        cnt[cnt1]++;
      return true;
    } else
      return false;
  }
  int ind2 = ite - can.begin();
  bool flag = dfs(cnt, can, ind2, cnt1 + 1, dp);
  if (flag) {
    if (cnt1 <= K)
      cnt[cnt1]++;
    dp[ind1] = cnt1;
    return true;
  } else
    return false;
}
int main() {
  long long N;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<int> can;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'o')
      can.push_back(i + 1);
  }
  int size = can.size();
  vector<int> cnt(K + 1, 0);
  vector<int> dp(size, 0);
  int flag = 0;
  for (int i = 0; i < size; i++) {
    if (dp[i] != 0)
      continue;
    int te;
    if (can[i] - C - 1 < can[0])
      te = 1;
    else {
      int ind =
          upper_bound(can.begin(), can.end(), can[i] - C - 1) - can.begin() - 1;
      te = dp[ind] + 1;
    }
    dfs(cnt, can, i, te, dp);
  }
  flag = 1;
  for (int i = 0; i < size; i++) {
    if (dp[i] == K)
      flag = 0;
  }
  if (flag == 1) {
    cout << endl;
    return 0;
  }
  for (int i = 0; i < size; i++) {
    if (dp[i] == 0)
      continue;
    if (cnt[dp[i]] == 1)
      cout << can[i] << endl;
  }
}
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> saitan(K);
  vector<int> saichi(K);

  int j = 0;
  for (int i = 0; i < N && j < K; i++) {
    if (S[i] == 'o') {
      saitan[j] = i;
      i += C;
      j++;
    }
  }

  j = 0;
  for (int i = 0; i < N && j < K; i++) {
    if (S[N - 1 - i] == 'o') {
      saichi[K - 1 - j] = N - 1 - i;
      i += C;
      j++;
    }
  }

  for (int i = 0; i < K; i++) {
    if (saitan[i] == saichi[i]) {
      cout << saitan[i] + 1 << endl;
    }
  }
}

Error: TLE

Fixed submission:

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

int main() {

  int N, K, C;
  cin >> N >> K >> C;

  string S;
  cin >> S;

  vector<int> saitan(K);
  vector<int> saichi(K);

  int j = 0;
  for (int i = 0; i < N && j < K; i++) {
    if (S[i] == 'o') {
      saitan[j] = i;
      i = i + C;
      j++;
    }
  }

  j = 0;
  for (int i = 0; i < N && j < K; i++) {
    if (S[N - 1 - i] == 'o') {
      saichi[K - 1 - j] = N - 1 - i;
      i = i + C;
      j++;
    }
  }

  for (int l = 0; l < N; l++) {
    if (find(saitan.begin(), saitan.end(), l) != saitan.end() &&
        find(saichi.begin(), saichi.end(), l) != saichi.end()) {
      cout << l + 1 << endl;
    }
  }
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

vector<int> buf;

int main(int argc, char *argv[]) {
  int N, K, C;
  string s;
  cin >> N >> K >> C;
  cin >> s;

  buf.resize(K, -1);

  int num = K;
  int cur = N - 1;

  while (cur >= 0) {
    if (s[cur] == 'x') {
      --cur;
      continue;
    }

    buf[--num] = cur;
    if (num == 0) {
      break;
    }

    cur -= C + 1;
  }

  cur = 0;
  num = 0;

  while (cur < N) {
    if (s[cur] == 'x') {
      ++cur;
      continue;
    }

    if (buf[num++] == cur) {
      cout << cur + 1 << endl;
    }

    if (num == K) {
      break;
    }

    cur += C + 1;
  }
}


Error: 0

Fixed submission:

#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

vector<int> buf;

int main(int argc, char *argv[]) {
  int N, K, C;
  string s;
  cin >> N >> K >> C;
  cin >> s;

  buf.resize(K, -1);

  int num = K;
  int cur = N - 1;

  while (cur >= 0) {
    if (s[cur] == 'x') {
      --cur;
      continue;
    }

    buf[--num] = cur;
    if (num == 0) {
      break;
    }

    cur -= C + 1;
  }

  cur = 0;
  num = 0;

  while (cur < N) {
    if (s[cur] == 'x') {
      ++cur;
      continue;
    }

    if (buf[num++] == cur) {
      cout << cur + 1 << endl;
    }

    if (num == N) {
      break;
    }

    cur += C + 1;
  }
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <queue>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long LL;

const int maxn = 200000 + 10;
int L[maxn][2], R[maxn][2];
char str[maxn];

int main() {
  int i, j, n, K, C;
  scanf("%d%d%d", &n, &K, &C);
  scanf("%s", str + 1);
  for (i = 1; i <= n; i++) {
    if (str[i] == 'x') {
      L[i][0] = max(L[i - 1][0], L[i - 1][1]);
      L[i][1] = L[i][0];
    } else {
      L[i][0] = max(L[i - 1][0], L[i - 1][1]);
      int v = 0;
      if (i - C > 1)
        v = L[i - C - 1][1];
      L[i][1] = v + 1;
    }
    L[i][0] = max(L[i][0], L[i - 1][0]);
    L[i][1] = max(L[i][1], L[i - 1][1]);
    // printf("i=%d L0=%d L1=%d\\n",i,L[i][0],L[i][1]);
  }
  for (i = n; i >= 1; i--) {
    if (str[i] == 'x') {
      R[i][0] = max(R[i + 1][0], R[i + 1][1]);
      R[i][1] = R[i][0];
    } else {
      R[i][0] = max(R[i + 1][0], R[i + 1][1]);
      int v = 0;
      if (i + C + 1 <= n)
        v = max(R[i + C + 1][1], R[i + C + 1][1]);
      R[i][1] = v + 1;
    }
    R[i][0] = max(R[i][0], R[i + 1][0]);
    R[i][1] = max(R[i][1], R[i + 1][1]);
    // printf("i=%d R0=%d R1=%d\\n",i,R[i][0],R[i][1]);
  }

  for (i = 1; i <= n; i++) {
    if (str[i] == 'x')
      continue;
    if (L[i][0] + R[i][0] == K - 1)
      printf("%d\\n", i);
  }
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <queue>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long LL;

const int maxn = 100000 + 10;
int L[maxn][2], R[maxn][2];
char str[maxn];

int main() {
  int i, j, n, K, C;
  scanf("%d%d%d", &n, &K, &C);
  scanf("%s", str + 1);
  for (i = 1; i <= n; i++) {
    if (str[i] == 'x') {
      L[i][0] = max(L[i - 1][0], L[i - 1][1]);
      L[i][1] = L[i][0];
    } else {
      L[i][0] = max(L[i - 1][0], L[i - 1][1]);
      int v = 0;
      if (i - C > 1)
        v = L[i - C - 1][1];
      L[i][1] = v + 1;
    }
    L[i][0] = max(L[i][0], L[i - 1][0]);
    L[i][1] = max(L[i][1], L[i - 1][1]);
    // printf("i=%d L0=%d L1=%d\\n",i,L[i][0],L[i][1]);
  }
  for (i = n; i >= 1; i--) {
    if (str[i] == 'x') {
      R[i][0] = max(R[i + 1][0], R[i + 1][1]);
      R[i][1] = R[i][0];
    } else {
      R[i][0] = max(R[i + 1][0], R[i + 1][1]);
      int v = 0;
      if (i + C + 1 <= n)
        v = max(R[i + C + 1][1], R[i + C + 1][1]);
      R[i][1] = v + 1;
    }
    R[i][0] = max(R[i][0], R[i + 1][0]);
    R[i][1] = max(R[i][1], R[i + 1][1]);
    // printf("i=%d R0=%d R1=%d\\n",i,R[i][0],R[i][1]);
  }

  for (i = 1; i <= n; i++) {
    if (str[i] == 'x')
      continue;
    if (L[i][0] + R[i][0] == K - 1)
      printf("%d\\n", i);
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

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

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

  string s;
  cin >> s;

  vector<int> a, b;

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

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

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

  return 0;
}

Error: WA

Fixed submission:

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

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

  string s;
  cin >> s;

  vector<int> a, b;

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

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

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

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

#include <iostream>
#include <string>

using namespace std;

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

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

  for (int i = 0; i < k; ++i)
    if (a[i] == b[i])
      cout << a[i] + 1 << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
char s[2000006];
int a[2000005], b[2000005];
int main() {
  int n, k, c;
  scanf("%d%d%d %s", &n, &k, &c, s);
  for (int i = 0, j = 0; i < n; i++)
    if (s[i] == 'o') {
      a[j++] = i;
      i += c;
    }
  for (int i = n - 1, j = k - 1; i >= 0; i--)
    if (s[i] == 'o') {
      b[j--] = i;
      i -= c;
    }
  for (int i = 0; i < k; i++)
    if (a[i] == b[i])
      printf("%d\\n", a[i] + 1);
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)

using namespace std;

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

  int N, K, C;
  string S;
  cin >> N >> K >> C >> S;

  vector<int> dp(N + 1);
  dp[N] = 0;

  RREP(i, N) {
    if (S[i] == 'x') {
      dp[i] = dp[i + 1];
    } else {
      int j = i + C + 1;
      dp[i] = max(dp[i + 1], 1 + (j < N ? dp[j] : 0));
    }
  }

  int i = 0;
  while (K > 0) {
    int first_o = -1;
    int next_i = -1;
    while (dp[i] >= K) {
      if (S[i] == 'o') {
        if (first_o == -1) {
          first_o = i;
          next_i = first_o + C + 1;
        } else {
          first_o = -1;
          break;
        }
      }
      ++i;
    }
    if (first_o != -1) {
      cout << (first_o + 1) << '\\n'; // 1-based indexing
    }
    i = next_i;
    --K;
  }
  cout << flush;

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)

using namespace std;

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

  int N, K, C;
  string S;
  cin >> N >> K >> C >> S;

  vector<int> dp(N + 1);
  dp[N] = 0;

  RREP(i, N) {
    if (S[i] == 'x') {
      dp[i] = dp[i + 1];
    } else {
      int j = i + C + 1;
      dp[i] = max(dp[i + 1], 1 + (j < N ? dp[j] : 0));
    }
  }

  int i = 0;
  while (i < N) {
    int first_o = -1;
    int next_i = -1;
    while (dp[i] >= K) {
      if (S[i] == 'o') {
        if (first_o == -1) {
          first_o = i;
          next_i = first_o + C + 1;
        } else {
          first_o = -1;
          break;
        }
      }
      ++i;
    }
    if (first_o != -1) {
      cout << (first_o + 1) << '\\n'; // 1-based indexing
    }
    i = next_i;
    --K;
  }
  cout << flush;

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

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
int a[maxn], b[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // freopen(".in","r",stdin);
  // freopen(".out","w",stdout);
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  int num = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      a[num++] = i;
      i += c;
    }
  }
  num = k - 1;
  for (int i = n - 1; i >= 0; i--) {
    if (num < 0)
      break;
    if (s[i] == 'o') {
      b[num--] = i;
      i -= c;
    }
  }
  for (int i = 0; i < k; i++)
    if (a[i] == b[i])
      cout << a[i] + 1 << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
int a[maxn], b[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // freopen(".in","r",stdin);
  // freopen(".out","w",stdout);
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  int num = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      a[num++] = i;
      i += c;
    }
  }
  num = k - 1;
  for (int i = n - 1; i >= 0; i--) {
    if (num < 0)
      break;
    if (s[i] == 'o') {
      b[num--] = i;
      i -= c;
    }
  }
  for (int i = 0; i < k; i++)
    if (a[i] == b[i])
      cout << a[i] + 1 << endl;
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int64_t N, K, C;
  cin >> N >> K >> C;
  vector<bool> vb(N);
  vector<int> vl(N, -1), vr(N, -1);
  char c;
  for (int i = 0; i < N; i++) {
    cin >> c;
    vb[i] = (c == 'o');
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (cnt >= K) {
      break;
    }
    if (!vb[i])
      continue;
    vl[i] = ++cnt;
    i += C;
  }
  int k = 0;
  for (int i = N - 1; i >= 0; i--) {
    if (k >= K) {
      break;
    }
    if (!vb[i])
      continue;
    k++;
    vr[i] = (cnt + 1) - k;
    i -= C;
  }
  queue<int> ans;
  for (int i = 0; i < N; i++) {
    if (vl[i] > 0 && vl[i] == vr[i]) {
      ans.push(i + 1);
    }
  }
  while (ans.size()) {
    cout << ans.front() << endl;
    ans.pop();
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int64_t MAXN = 200010;
int64_t N, K, C, sum = 0;
vector<bool> Work(MAXN, false);
vector<int64_t> Count(MAXN, 0);
queue<int64_t> Ans;

int64_t dfs(int64_t cur, int64_t cnt) {
  if (cnt == K) {
    sum++; // Kに到達した数
    return 1;
  }
  if (cur >= N)
    return 0;
  if (!Work.at(cur))
    return dfs(cur + 1, cnt);
  int64_t rest = dfs(cur + 1, cnt);
  int64_t work = dfs(cur + C + 1, cnt + 1);
  Count.at(cur) += work;
  return rest + work;
}

int main() {
  cin >> N >> K >> C;
  char c;
  for (int i = 0; i < N; i++) {
    cin >> c;
    if (c == 'o')
      Work.at(i) = true;
  }
  dfs(0, 0);
  int64_t ans = 0;
  for (int i = 0; i < N; i++) {
    if (Count.at(i) == sum && Work.at(i))
      cout << i + 1 << endl;
  }
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {
  int x;
  cin >> x;
  return x;
}
ll lin() {
  ll x;
  cin >> x;
  return x;
}
string sin() {
  string x;
  cin >> x;
  return x;
}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

bool ifprime(int x) {
  if (x == 1)
    return false;
  if (x == 2)
    return true;
  if (x % 2 == 0)
    return false;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return false;
  }
  return true;
}
ll mod(ll x, ll y) {
  if (x >= 0 || x % y == 0)
    return x % y;
  return y + x % y;
} // mod including minus
ll dv0(ll x, ll y) {
  if (x >= 0 || x % y == 0)
    return x / y;
  return x / y - 1;
} // rnd down
ll dv1(ll x, ll y) {
  if (x % y == 0)
    return dv0(x, y);
  return dv0(x, y) + 1;
} // rnd up

// Start from Here
int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  int a[K], b[K];
  int i = 0;
  int cnt = 0;
  while (i < N && cnt < K) {
    if (S.at(i) == 'o') {
      a[cnt] = i;
      cnt++;
      i += C + 1;
    } else {
      i++;
    }
  }
  i = 0;
  cnt = 0;
  while (i < N && cnt < K) {
    if (S.at(N - 1 - i) == 'o') {
      b[K - cnt - 1] = N - 1 - i;
      cnt++;
      i += C + 1;
    } else {
      i++;
    }
  }
  rep(i, K) {
    if (a[i] == b[i]) {
      cout << a[i] + 1 << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {
  int x;
  cin >> x;
  return x;
}
ll lin() {
  ll x;
  cin >> x;
  return x;
}
string sin() {
  string x;
  cin >> x;
  return x;
}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

bool ifprime(int x) {
  if (x == 1)
    return false;
  if (x == 2)
    return true;
  if (x % 2 == 0)
    return false;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return false;
  }
  return true;
}
ll mod(ll x, ll y) {
  if (x >= 0 || x % y == 0)
    return x % y;
  return y + x % y;
} // mod including minus
ll dv0(ll x, ll y) {
  if (x >= 0 || x % y == 0)
    return x / y;
  return x / y - 1;
} // rnd down
ll dv1(ll x, ll y) {
  if (x % y == 0)
    return dv0(x, y);
  return dv0(x, y) + 1;
} // rnd up

// Start from Here
int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  queue<int> Q;
  queue<int> A;
  int a;
  int i = 0;
  int cnt = 0;
  while (i < N && cnt < K) {
    if (S.at(i) == 'o') {
      cnt++;
      Q.push(i);
      i += C + 1;
    } else {
      i++;
    }
  }
  while (!Q.empty()) {
    a = Q.front();
    Q.pop();
    cnt = 0;
    i = 0;
    while (i < N && cnt < K) {
      if (S.at(i) == 'o' && i != a) {
        cnt++;
        i += C + 1;
      } else {
        i++;
      }
    }
    if (cnt != K) {
      A.push(a);
    }
  }
  while (!A.empty()) {
    cout << A.front() + 1 << endl;
    A.pop();
  }
}