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

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

#define mp make_pair

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);

  // freopen("a.txt", "r", stdin);

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

  vector<int> good;

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

  n = good.size();
  vector<int> dp(n);

  for (int i = n - 1; i >= 0; --i) {
    int it = upper_bound(good.begin(), good.end(), good[i] + c) - good.begin();
    if (it < good.size()) {
      dp[i] = dp[it] + 1;
    } else {
      dp[i] = 1;
    }
  }

  int when = -1e9, cnt = 0;

  for (int i = 0; i < n; ++i) {
    int L = upper_bound(good.begin(), good.end(), when + c) - good.begin();
    L = max(L, i + 1);
    int add = 0;
    if (L < good.size())
      add = dp[L];
    if (add + cnt < k) {
      cout << good[i] + 1 << "\\n";
    }
    if (good[i] > when + c) {
      when = good[i];
      cnt++;
    }
  }

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

#define mp make_pair

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);

  freopen("a.txt", "r", stdin);

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

  vector<int> good;

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

  n = good.size();
  vector<int> dp(n);

  for (int i = n - 1; i >= 0; --i) {
    int it = upper_bound(good.begin(), good.end(), good[i] + c) - good.begin();
    if (it < good.size()) {
      dp[i] = dp[it] + 1;
    } else {
      dp[i] = 1;
    }
  }

  int when = -1e9, cnt = 0;

  for (int i = 0; i < n; ++i) {
    int L = upper_bound(good.begin(), good.end(), when + c) - good.begin();
    L = max(L, i + 1);
    int add = 0;
    if (L < good.size())
      add = dp[L];
    if (add + cnt < k) {
      cout << good[i] + 1 << "\\n";
    }
    if (good[i] > when + c) {
      when = good[i];
      cnt++;
    }
  }

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

/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
 **/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int, int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1000000007

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
//*find_by_order(); order_of_key();

int l[200010], r[200010];
int main() {
  ios_base::sync_with_stdio(false);

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

  int trab = 0;
  for (int i = 0; i < n;) {
    if (trab >= k)
      break;
    if (s[i] == 'o') {
      l[trab] = i;
      trab++;
      i += c + 1;
    } else {
      i++;
    }
  }
  trab = k - 1;
  for (int i = n - 1; i >= 0;) {
    if (trab < 0)
      break;
    if (s[i] == 'o') {
      r[trab] = i;
      trab--;
      i -= c + 1;
    } else {
      i--;
    }
  }

  for (int i = 0; i < k; i++) {
    if (l[i] == r[i]) {
      cout << l[i] + 1 << "\\n";
    }
  }
}


Error: 0

Fixed submission:

/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
 **/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int, int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1000000007

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
//*find_by_order(); order_of_key();

int l[200001], r[200001];
int main() {
  ios_base::sync_with_stdio(false);

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

  int trab = 0;
  for (int i = 0; i < n;) {
    if (s[i] == 'o') {
      l[trab] = i;
      trab++;
      i += c + 1;
    } else {
      i++;
    }
  }
  trab = k - 1;
  for (int i = n - 1; i >= 0;) {
    if (s[i] == 'o') {
      r[trab] = i;
      trab--;
      i -= c + 1;
    } else {
      i--;
    }
  }

  for (int i = 0; i < k; i++) {
    if (l[i] == r[i]) {
      cout << l[i] + 1 << "\\n";
    }
  }
}
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;
  s = " " + s;
  vector<int> L(k + 1);

  int tmp = 1;
  for (int i = 1; i <= n; i++) {
    if (tmp > k)
      break;
    if (s[i] == 'o') {
      L[tmp] = i;
      ++tmp;
      i += c;
    }
  }

  vector<int> R(k + 1);
  tmp = k;
  for (int i = n; i >= 1; i--) {
    if (tmp < 1)
      break;
    if (s[i] == 'o') {
      R[tmp] = i;
      --tmp;
      i -= c;
    }
  }

  // for(int i=1;i<=k;i++)cout<<L[i]<<" ";
  // cout<<endl;
  // for(int i=1;i<=k;i++)cout<<R[i]<<" ";
  // cout<<endl;

  bool flag = false;
  for (int i = 1; i <= k; i++) {
    if (L[i] == R[i]) {
      flag = true;
      cout << L[i] << endl;
    }
  }

  if (!flag)
    cout << endl;
  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  // 解説を読んだままやってみている……つもり
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  s = " " + s;
  vector<int> L(k + 1);

  int tmp = 1;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'o') {
      L[tmp] = i;
      ++tmp;
      i += c;
    }
  }

  vector<int> R(k + 1);
  tmp = k;
  for (int i = n; i >= 1; i--) {
    if (s[i] == 'o') {
      R[tmp] = i;
      --tmp;
      i -= c;
    }
  }

  // for(int i=1;i<=k;i++)cout<<L[i]<<" ";
  // cout<<endl;
  // for(int i=1;i<=k;i++)cout<<R[i]<<" ";
  // cout<<endl;

  bool flag = false;
  for (int i = 1; i <= k; i++) {
    if (L[i] == R[i]) {
      flag = true;
      cout << L[i] << endl;
    }
  }

  if (!flag)
    cout << 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 zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vector<vector<int>> ans(2, vector<int>(k, -1));
  int cnt = 0;
  rep(i, n) {
    if (s[i] == 'x')
      continue;
    else {
      ans[0][cnt] = i;
      i += c;
      cnt++;
      if (cnt >= k)
        break;
    }
  }
  cnt = k - 1;
  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == 'x')
      continue;
    else {
      ans[1][cnt] = i;
      i -= c;
      cnt--;
      if (cnt < 0)
        break;
    }
  }
  rep(i, k) {
    if (ans[0][i] == ans[1][i])
      cout << ans[0][i] + 1 << endl;
  }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vector<vector<int>> ans(2, vector<int>(k, -1));
  int cnt = 0;
  rep(i, n) {
    if (s[i] == 'x')
      continue;
    else {
      ans[0][cnt] = i;
      i += c;
      cnt++;
      if (cnt >= n)
        break;
    }
  }
  cnt = k - 1;
  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == 'x')
      continue;
    else {
      ans[1][cnt] = i;
      i -= c;
      cnt--;
      if (cnt < 0)
        break;
    }
  }
  rep(i, k) {
    if (ans[0][i] == ans[1][i])
      cout << ans[0][i] + 1 << endl;
  }
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main() {
  int N, K, C;
  int i;
  int *L, *R;

  string s;
  ULL patern = 0;
  int count;
  cin >> N >> K >> C;
  R = new int[K];
  L = new int[K];
  cin >> s;
  count = 0;
  for (i = 0; i < N && count < K;) {
    if (s[i] == 'o') {
      L[count++] = i;
      i += C + 1;
    } else {
      i++;
    }
  }
  count = 0;
  for (i = N - 1; i >= 0 && count < K;) {
    if (s[i] == 'o') {
      R[K - count - 1] = i;
      count++;
      i -= C + 1;
    } else {
      i--;
    }
  }
  /*
  for(i=0;i<K;i++){
      cout << "L:" << L[i]+1 << " R:" << R[i]+1 << endl;
  }
  */
  for (i = 0; i < K; i++) {
    if (L[i] == R[i]) {
      cout << L[i] + 1 << endl;
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

void process();
void process(int N, int K, int C, ULL &patern, int *allow_work_day,
             int num_of_work_day, int *work_day, int *num, int pos,
             int work_pos, int today);
int main() {
  int N, K, C;
  int *allow_work_day;
  int *work_day;
  int num_of_work_day;
  int *num;
  int i;
  string s;
  ULL patern = 0;

  cin >> N >> K >> C;
  allow_work_day = new int[N];
  work_day = new int[K];
  num = new int[N];
  cin >> s;
  for (i = 0; i < N; i++) {
    if (s[i] == 'o') {
      allow_work_day[num_of_work_day++] = i;
    }
  }
  process(N, K, C, patern, allow_work_day, num_of_work_day, work_day, num, 0, 0,
          -C * 2);
  for (i = 0; i < num_of_work_day; i++) {
    if (num[allow_work_day[i]] == patern) {
      cout << allow_work_day[i] + 1 << endl;
    }
  }
  return 0;
}

void process(int N, int K, int C, ULL &patern, int *allow_work_day,
             int num_of_work_day, int *work_day, int *num, int pos,
             int work_pos, int today) {
  int i;
  if (pos == K) {
    patern++;
    i = 0;
    for (i = 0; i < K; i++) {
      num[work_day[i]]++;
    }
    return;
  }

  if (work_pos == num_of_work_day) {
    return;
  }
  for (i = work_pos; i < num_of_work_day; i++) {
    if (allow_work_day[i] - today > C)
      break;
  }
  for (; i < num_of_work_day; i++) {
    if (num_of_work_day - i + 1 < K - pos) {
      return;
    }
    work_day[pos] = allow_work_day[i];
    process(N, K, C, patern, allow_work_day, num_of_work_day, work_day, num,
            pos + 1, work_pos + 1, allow_work_day[i]);
  }
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define VI vector<int>
#define pii pair<int, int>
#define INF 0x3f3f3f3f
using namespace std;
const int MAXN = 2e5;
char S[MAXN + 10];
int dp[2][MAXN + 10];
int n, k, x;
int main() {
  scanf("%d %d %d", &n, &k, &x);
  scanf("%s", S);
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    if (S[i - 1] == 'x')
      dp[0][i] = dp[0][i - 1];
    else
      dp[0][i] = 1 + (i - x - 1 >= 0 ? dp[0][i - x - 1] : 0);
  }
  dp[1][n + 1] = 0;
  for (int i = n; i > 0; i--) {
    if (S[i - 1] == 'x')
      dp[1][i] = dp[1][i + 1];
    else
      dp[1][i] = 1 + (i + x + 1 <= n + 1 ? dp[1][i + x + 1] : 0);
  }
  // for(int i = 1; i <= n; i++) printf("%d ", dp[1][i]); printf("\\n");
  for (int i = 0; i < n; i++) {
    if (dp[0][i] + dp[1][i + 2] < k)
      printf("%d\\n", i + 1);
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define VI vector<int>
#define pii pair<int, int>
#define INF 0x3f3f3f3f
using namespace std;
const int MAXN = 1e5;
char S[MAXN + 10];
int dp[2][MAXN + 10];
int n, k, x;
int main() {
  scanf("%d %d %d", &n, &k, &x);
  scanf("%s", S);
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    if (S[i - 1] == 'x')
      dp[0][i] = dp[0][i - 1];
    else
      dp[0][i] = 1 + (i - x - 1 >= 0 ? dp[0][i - x - 1] : 0);
  }
  dp[1][n + 1] = 0;
  for (int i = n; i > 0; i--) {
    if (S[i - 1] == 'x')
      dp[1][i] = dp[1][i + 1];
    else
      dp[1][i] = 1 + (i + x + 1 <= n + 1 ? dp[1][i + x + 1] : 0);
  }
  // for(int i = 1; i <= n; i++) printf("%d ", dp[1][i]); printf("\\n");
  for (int i = 0; i < n; i++) {
    if (dp[0][i] + dp[1][i + 2] < k)
      printf("%d\\n", i + 1);
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, c, i, j;
  string s;
  cin >> n >> k >> c >> s;
  vector<int> l(k), r(k);
  j = 0;
  for (i = 0; i < n; i++) {
    if (s.at(i) == 'o') {
      l.at(j) = i + 1;
      j++;
      i += c;
    }
    if (j == k)
      break;
  }
  j = k - 1;
  for (i = n - 1; i >= 0; i--) {
    if (s.at(i) == 'o') {
      r.at(j) = i + 1;
      j--;
      i -= c;
    }
    if (j == -1)
      break;
  }
  for (i = 0; i < k; i++)
    if (l.at(i) == r.at(i))
      cout << l.at(i) << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, c, i, j, m;
  string s;
  cin >> n >> k >> c >> s;
  for (i = 0; i < n; i++) {
    if (s.at(i) == 'o') {
      s.at(i) = 'x';
      m = 0;
      for (j = 0; j < n; j++) {
        if (s.at(j) == 'o') {
          m++;
          j += c;
        }
        if (m == k)
          break;
      }
      if (m < k)
        cout << i + 1 << endl;
      s.at(i) = 'o';
    }
  }
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep2(i, N) for (int i = 1; i <= N; i++)
using namespace std;
long long INF = 1e18;
long long mod = 1e9 + 7;

long long n, k, c;
string s;
vector<int> getWorkday_L() {
  int now = 0;
  vector<int> ret;
  for (int i = 0; i < n; i++) {
    if (now <= 0 && s[i] != 'x') {
      ret.push_back(i + 1);
      now = c;
    } else {
      now--;
    }
  }
  return ret;
}
vector<int> getWorkday_R() {
  int now = 0;
  int num = k;
  vector<int> ret;
  for (int i = n - 1; i > -1; i--) {
    if (now <= 0 && s[i] != 'x') {
      ret.insert(ret.begin(), i + 1);
      now = c;
    } else {
      now--;
    }
  }
  return ret;
}
// status unsolved
int main() {

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

  vector<int> w = getWorkday_L();
  vector<int> R = getWorkday_R();

  if (w.size() > k) {
    return 0;
  } else {

    rep(i, w.size()) {
      if (R[i] == w[i]) {
        cout << R[i] << endl;
      }
    }
  }
  return 0;
}
/*


*/


Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep2(i, N) for (int i = 1; i <= N; i++)
using namespace std;
long long INF = 1e18;
long long mod = 1e9 + 7;

long long n, k, c;
string s;
vector<int> getWorkday_L() {
  int now = 0;
  vector<int> ret;
  for (int i = 0; i < n; i++) {
    if (now <= 0 && s[i] != 'x') {
      ret.push_back(i + 1);
      now = c;
    } else {
      now--;
    }
  }
  return ret;
}
vector<int> getWorkday_R() {
  int now = 0;
  int num = k;
  vector<int> ret(num);
  for (int i = n - 1; i > -1; i--) {
    if (now <= 0 && s[i] != 'x') {
      ret[--num] = i + 1;
      now = c;
    } else {
      now--;
    }
  }
  return ret;
}
// status unsolved
int main() {

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

  vector<int> w = getWorkday_L();
  vector<int> R = getWorkday_R();

  if (w.size() > k) {
    return 0;
  } else {

    rep(i, w.size()) {
      if (R[i] == w[i]) {
        cout << R[i] << endl;
      }
    }
  }
  return 0;
}
/*


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

#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

  vector<int> A(K);
  vector<int> B(K);

  int day_before = -3e+6;
  int count = 0;
  for (int i = 0; i < N; ++i) {
    if (S[i] == 'o' and (i - day_before) > C) {
      A.at(count) = i + 1;
      day_before = i;
      ++count;
      if (count >= K) {
        break;
      }
    }
  }

  day_before = 3e+6;
  count = K - 1;
  for (int i = N - 1; i >= 0; --i) {
    if (S[i] == 'o' and (day_before - i) > C) {
      B.at(count) = i + 1;
      day_before = i;
      --count;
      if (count < 0) {
        break;
      }
    }
  }

  /*for ( int i = 0; i < K; ++i){
      cout << A.at(i) << B.at(i) << endl;
  }*/

  int none = 0;
  for (int i = 0; i < K; ++i) {
    if (A.at(i) == B.at(i)) {
      cout << A.at(i) << endl;
      none = 1;
    }
  }
  if (none == 0) {
    cout << endl;
  }

  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

  vector<int> A(K);
  vector<int> B(K);

  int day_before = -C - 1;
  int count = 0;
  for (int i = 0; i < N; ++i) {
    if (S[i] == 'o' and (i - day_before) > C) {
      A.at(count) = i + 1;
      day_before = i;
      ++count;
      if (count > K) {
        break;
      }
    }
  }

  day_before = N + C + 1;
  count = K - 1;
  for (int i = N - 1; i >= 0; --i) {
    if (S[i] == 'o' and (day_before - i) > C) {
      B.at(count) = i + 1;
      day_before = i;
      --count;
      if (count < 0) {
        break;
      }
    }
  }

  int none = 0;
  for (int i = 0; i < K; ++i) {
    if (A.at(i) == B.at(i)) {
      cout << A.at(i) << endl;
      none = 1;
    }
  }
  if (none == 0) {
    cout << endl;
  }

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

/*Code by Codercjh*/
#include <bits/stdc++.h>
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)
#define rf(i, a, b) for (int i = (a); i >= (b); --i)
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
using namespace std;
typedef long long ll;
template <typename T> inline void read(T &x) {
  char c = getchar();
  T fh = 0;
  bool f = false;
  while (!isdigit(c))
    f |= (c == '-'), c = getchar();
  while (isdigit(c))
    fh = (fh << 1) + (fh << 3) + (c ^ 48), c = getchar();
  x = f ? -fh : fh;
  return;
}
int n, k, c, cnt, ans;
char s[200005];
int l[200005], r[200005];
int main() {
  read(n), read(k), read(c);
  cin >> s + 1;
  fr(i, 1, n) if (s[i] == 'o') l[++cnt] = i, i += c;
  int cnt1 = k;
  rf(i, n, 1) {
    if (s[i] == 'o')
      r[cnt1--] = i, i -= c;
    if (!cnt1)
      break;
  }
  fr(i, 1, k) if (l[i] == r[i]) printf("%d\\n", l[i]);
  return 0;
}


Error: 0

Fixed submission:

/*Code by Codercjh*/
#include <bits/stdc++.h>
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)
#define rf(i, a, b) for (int i = (a); i >= (b); --i)
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
using namespace std;
typedef long long ll;
template <typename T> inline void read(T &x) {
  char c = getchar();
  T fh = 0;
  bool f = false;
  while (!isdigit(c))
    f |= (c == '-'), c = getchar();
  while (isdigit(c))
    fh = (fh << 1) + (fh << 3) + (c ^ 48), c = getchar();
  x = f ? -fh : fh;
  return;
}
int n, k, c, cnt, ans;
char s[200005];
int l[200005], r[200005];
int main() {
  read(n), read(k), read(c);
  cin >> s + 1;
  fr(i, 1, n) if (s[i] == 'o') l[++cnt] = i, i += c;
  int cnt1 = k;
  rf(i, n, 1) if (s[i] == 'o') r[cnt1--] = i, i -= c;
  fr(i, 1, k) if (l[i] == r[i]) printf("%d\\n", l[i]);
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

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

const int INF = 0x3f3f3f3f;
const int M = 2e5 + 5;
int n, k, c;
char s[M];

int l[M], r[M];

int ml[M], mr[M];

inline void cmin(int &x, int y) {
  if (x > y)
    x = y;
}
inline void cmax(int &x, int y) {
  if (x < y)
    x = y;
}

int main() {
  // freopen("E.in","r",stdin);
  scanf("%d%d%d", &n, &k, &c);
  scanf("%s", s + 1);
  memset(ml, INF, sizeof(ml));
  for (int i = 1; i <= n; i++) {
    l[i] = l[i - 1];
    if (s[i] != 'x')
      l[i] = max(l[i], i - c - 1 >= 1 ? l[i - c - 1] + 1 : 1);
    cmin(ml[l[i]], i);
  }
  r[n + 1] = k;
  // memset(r,INF,sizeof(r));
  for (int i = n; i >= 1; i--) {
    r[i] = r[i + 1];
    if (s[i] != 'x')
      r[i] = min(r[i], i + c + 1 <= n ? r[i + c + 1] - 1 : k);
    if (r[i] > 0)
      cmax(mr[r[i]], i);
  }
  // for(int i=1;i<=k;i++)
  // 	cout<<ml[i]<<" "<<mr[i]<<endl;
  for (int i = 1; i <= n; i++) {
    // assert(0<=l[i]&&l[i]<M);
    if (i == ml[l[i]] && ml[l[i]] == mr[l[i]])
      printf("%d\\n", i);
  }
  return 0;
}


Error: 0

Fixed submission:

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

const int INF = 0x3f3f3f3f;
const int M = 2e5 + 5;
int n, k, c;
char s[M];

int l[M], r[M];

int ml[M], mr[M];

inline void cmin(int &x, int y) {
  if (x > y)
    x = y;
}
inline void cmax(int &x, int y) {
  if (x < y)
    x = y;
}

int main() {
  // freopen("E.in","r",stdin);
  scanf("%d%d%d", &n, &k, &c);
  scanf("%s", s + 1);
  memset(ml, INF, sizeof(ml));
  for (int i = 1; i <= n; i++) {
    l[i] = l[i - 1];
    if (s[i] != 'x')
      l[i] = max(l[i], i - c - 1 >= 1 ? l[i - c - 1] + 1 : 1);
    cmin(ml[l[i]], i);
  }
  r[n + 1] = k;
  memset(r, INF, sizeof(r));
  for (int i = n; i >= 1; i--) {
    r[i] = r[i + 1];
    if (s[i] != 'x')
      r[i] = min(r[i], i + c + 1 <= n ? r[i + c + 1] - 1 : k);
    if (r[i] > 0)
      cmax(mr[r[i]], i);
  }
  // for(int i=1;i<=k;i++)
  // 	cout<<ml[i]<<" "<<mr[i]<<endl;
  for (int i = 1; i <= n; i++) {
    if (i == ml[l[i]] && ml[l[i]] == mr[l[i]])
      printf("%d\\n", i);
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

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

const int nm = 2e5;
int n, k, c, l[nm], r[nm];
string s;

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

  for (int i = 0, count = 0; i < n; i++) {
    if (s[i] == 'o') {
      count++;
      l[count] = i;
      i += c;
    }
  }
  for (int i = n - 1, count = 0; i >= 0; i--) {
    if (s[i] == 'o') {
      count++;
      r[count] = i;
      i -= c;
    }
  }
  l[0] = l[1] - c;
  r[0] = r[1] + c;

  for (int i = 0, inf, sup, mid, left, right; i < n; i++) {
    if (s[i] == 'x')
      continue;
    inf = 0;
    sup = k + 1;
    while (sup - inf > 1) {
      mid = (sup + inf) / 2;
      if (l[mid] < i)
        inf = mid;
      else
        sup = mid;
    }
    left = inf;
    inf = 0;
    sup = k + 1;
    while (sup - inf > 1) {
      mid = (sup + inf) / 2;
      if (r[mid] > i)
        inf = mid;
      else
        sup = mid;
    }
    right = inf;
    if (left + right < k)
      cout << i + 1 << endl;
    else if (left + right == k) {
      if (r[right] - l[left] <= c)
        cout << i + 1 << endl;
    }
  }
}


Error: TLE

Fixed submission:

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

int n, k, c;
string s;

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

  for (int i = 0, count; i < n; i++) {
    count = 0;
    for (int j = 0; j < n; j++) {
      if (s[j] == 'o' && j != i) {
        count++;
        j += c;
      }
    }
    if (count < k)
      cout << i + 1 << endl;
  }
}