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

#include "bits/stdc++.h"

using namespace std;

using u32 = uint32_t;
using u64 = uint64_t;
using ll = long long;

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

  int n, k, c;
  string s;
#if 1
  cin >> n >> k >> c >> s;
#else
  // Generate test case
  n = 10;
  k = 10;
  c = 2;
  for (int i = 0; i < n; i++) {
    s += (rand() % 2 == 0) ? 'o' : 'x';
  }
#endif

  vector<int> workdays(k);
  int wdPos = 0;

  stack<int> results;

  // workdaysを全部左に配置
  {
    for (int i = 0, day = 0; i < k; i++) {
      if (day >= n)
        return 0;
      while (s[day] == 'x') {
        day++;
        if (day >= n)
          return 0;
      }
      // この日が一番はやい出勤
      workdays[i] = day;
      day += c + 1;
    }
  }

  // workdaysを右から逆順にループ
  int day = n - 1;
  for (int i = k - 1; i >= 0; i--) {
    // なるべく右にできる場所を探す
    while (s[day] == 'x') {
      day--;
    }
    // この日が一番おそい出勤
    // 一番はやい出勤とイコールなら、この日は不動 = result列に追加
    if (day == workdays[i]) {
      results.push(day);
    }
    day -= c + 1;
  }

  while (results.size() > 0) {
    cout << (results.top() + 1) << '\\n';
    results.pop();
  }
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"

using namespace std;

using u32 = uint32_t;
using u64 = uint64_t;
using ll = long long;

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

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

  vector<int> stack(k + 1);
  stack[k] = INT32_MAX;
  int stackPos = 0;
  string s2(s);

  int day = 0;
  while (true) {
    if (day >= n) {
      // 日数がオーバー
      if (--stackPos < 0) {
        break;
      }
      day = stack[stackPos] + 1;
    } else if (s[day] == 'x') {
      // はたらかん
      day++;
    } else {
      // はたらける
      stack[stackPos] = day;
      if (stackPos >= k - 1) {
        // はたらけるパターンきまったぜ
        // はたらかなくていい日を記憶
        {
          int c = 0;
          for (int i = 0; i < n; i++) {
            if (i == stack[c]) {
              c++;
              continue;
            }
            if (s2[i] == 'o') {
              s2[i] = 'x';
            }
          }
        }
#if 0
        // Print this pattern
        for (int i = 0; i <= stackPos; i++) {
          cout << stack[i] << ',';
        }
        cout << '\\n';
#endif
        day++;
      } else {
        day += c + 1;
        stackPos++;
      }
    }
  }

#if 0
  cout << s2 << '\\n';
#endif

  day = 1;
  for (auto c : s2) {
    if (c == 'o') {
      cout << day << '\\n';
    }
    day++;
  }
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int n, k, c;
string s;

bool solve(void) {
  int i, j;
  int ans = 0;
  for (i = 0; i < n; i++) {
    if (s[i] == 'o') {
      ans++;
      if (ans == k) {
        return true;
      }
      i = i + c;
    }
  }
  return false;
}

int main() {
  int i, j;

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

  int *mae = new int[k];
  int *usiro = new int[k];

  mae[0] = usiro[0] = 0;
  j = 0;

  for (i = 0; i < n; i++) {
    if (s[i] == 'o') {
      if (j < k) {
        mae[j] = i;
        j++;
      }
      i = i + c;
    }
  }

  j = k - 1;
  for (i = n - 1; i >= 0; i--) {
    if (s[i] == 'o') {
      if (j >= 0) {
        usiro[j] = i;
        j--;
      }
      i = i - c;
    }
  }

  for (j = 0; j < k; j++) {
    if (mae[j] == usiro[j]) {
      cout << mae[j] + 1 << endl;
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

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

int n, k, c;
string s;

bool solve(void) {
  int i, j;
  int ans = 0;
  for (i = 0; i < n; i++) {
    if (s[i] == 'o') {
      ans++;
      if (ans == k) {
        return true;
      }
      i = i + c;
    }
  }
  return false;
}

int main() {
  int i, j;

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

  bool *mae = new bool[n];
  bool *usiro = new bool[n];

  for (i = 0; i < n; i++) {
    mae[i] = usiro[i] = false;
  }

  for (i = 0; i < n; i++) {
    if (s[i] == 'o') {
      mae[i] = true;
      i = i + c;
    }
  }
  for (i = n - 1; i >= 0; i--) {
    if (s[i] == 'o') {
      usiro[i] = true;
      i = i - c;
    }
  }

  for (i = 0; i < n; i++) {
    if (mae[i] == true && usiro[i] == true) {
      s[i] = 'x';
      if (!solve()) {
        cout << i + 1 << endl;
      }
      s[i] = 'o';
    }
  }

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

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i, m, n) for (ll i = (m); i < (n); i++)
#define rrep(i, m, n) for (ll i = (m); i >= (n); i--)
#define printa(x, n)                                                           \\
  for (ll i = 0; i < n; i++) {                                                 \\
    cout << (x[i]) << " \\n"[i == n - 1];                                       \\
  };
void print() {}
template <class H, class... T> void print(H &&h, T &&...t) {
  cout << h << " \\n"[sizeof...(t) == 0];
  print(forward<T>(t)...);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<ll> pos;
  rep(i, 0, N) {
    if (S[i] == 'o')
      pos.push_back(i);
  }
  ll cnt1[200010] = {}, cnt2[200010] = {};
  ll cur = pos[0];
  cnt1[pos[0]] = 1;
  ll sz = pos.size();
  rep(i, 0, K - 1) {
    ll val = cur + C + 1;
    ll nxt = lower_bound(pos.begin(), pos.end(), val) - pos.begin();
    cnt1[pos[nxt]] = i + 2;
    cur = pos[nxt];
  }
  cur = pos[sz - 1];
  cnt2[pos[sz - 1]] = K;
  rep(i, 0, K - 1) {
    ll val = cur - C - 1;
    ll nxt = upper_bound(pos.begin(), pos.end(), val) - pos.begin();
    cnt2[pos[nxt - 1]] = K - 1 - i;
    cur = pos[nxt - 1];
  }
  // printa(cnt, N);
  rep(i, 0, N) {
    if (cnt1[i] == cnt2[i] && cnt1[i] != 0) {
      print(i + 1);
    }
  }
}


Error: 0

Fixed submission:

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i, m, n) for (ll i = (m); i < (n); i++)
#define rrep(i, m, n) for (ll i = (m); i >= (n); i--)
#define printa(x, n)                                                           \\
  for (ll i = 0; i < n; i++) {                                                 \\
    cout << (x[i]) << " \\n"[i == n - 1];                                       \\
  };
void print() {}
template <class H, class... T> void print(H &&h, T &&...t) {
  cout << h << " \\n"[sizeof...(t) == 0];
  print(forward<T>(t)...);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<ll> pos;
  rep(i, 0, N) {
    if (S[i] == 'o')
      pos.push_back(i);
  }
  ll cnt[200010] = {};
  ll cur = pos[0];
  cnt[pos[0]]++;
  ll sz = pos.size();
  rep(i, 0, K - 1) {
    ll val = cur + C + 1;
    ll nxt = lower_bound(pos.begin(), pos.end(), val) - pos.begin();
    cnt[pos[nxt]]++;
    cur = pos[nxt];
  }
  cur = pos[sz - 1];
  cnt[pos[sz - 1]]++;
  rep(i, 0, K - 1) {
    ll val = cur - C - 1;
    ll nxt = upper_bound(pos.begin(), pos.end(), val) - pos.begin();
    cnt[pos[nxt - 1]]++;
    cur = pos[nxt - 1];
  }
  // printa(cnt, N);
  rep(i, 0, N) {
    if (cnt[i] >= 2) {
      print(i + 1);
    }
  }
  if (N > 5000)
    exit(1);
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

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

#define int long long
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

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

  int ak[200010];

  {
    int at[200010];
    at[n] = n;
    for (int i = n - 1; i >= 0; i--) {
      at[i] = (s[i] == 'o' ? i : at[i + 1]);
    }

    int idx = at[0];
    for (int i = 0; i < k; i++) {
      ak[i] = idx + 1;
      idx = at[idx + c + 1];
    }
  }

  reverse(s.begin(), s.end());

  int bk[200010];

  {
    int at[200010];
    at[n] = n;
    for (int i = n - 1; i >= 0; i--) {
      at[i] = (s[i] == 'o' ? i : at[i + 1]);
    }

    int idx = at[0];
    for (int i = 0; i < k; i++) {
      bk[k - i - 1] = n - idx;
      idx = at[idx + c + 1];
    }
  }

  for (int i = 0; i < k; i++) {
    if (ak[i] == bk[i]) {
      cout << ak[i] << endl;
    }
  }

  return 0;
}


Error: 0

Fixed submission:

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

#define int long long
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

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

  int ak[100010];

  {
    int at[100010];
    at[n] = n;
    for (int i = n - 1; i >= 0; i--) {
      at[i] = (s[i] == 'o' ? i : at[i + 1]);
    }

    int idx = at[0];
    for (int i = 0; i < k; i++) {
      ak[i] = idx + 1;
      idx = at[idx + c + 1];
    }
  }

  reverse(s.begin(), s.end());

  int bk[100010];

  {
    int at[100010];
    at[n] = n;
    for (int i = n - 1; i >= 0; i--) {
      at[i] = (s[i] == 'o' ? i : at[i + 1]);
    }

    int idx = at[0];
    for (int i = 0; i < k; i++) {
      bk[k - i - 1] = n - idx;
      idx = at[idx + c + 1];
    }
  }

  for (int i = 0; i < k; i++) {
    if (ak[i] == bk[i]) {
      cout << ak[i] << endl;
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC161E() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  ++C;
  vi X(N), Y(N);
  X[0] = S[0] == 'x' ? 0 : 1;
  Y[N - 1] = S[N - 1] == 'x' ? 0 : 1;

  for (int i = 1; i < N; ++i) {
    if (i < C) {
      X[i] = max(X[i - 1], S[i] == 'x' ? 0 : 1);
      Y[N - 1 - i] = max(Y[N - i], S[i] == 'x' ? 0 : 1);
    } else {
      X[i] = max(X[i - 1], X[i - C] + (S[i] == 'x' ? 0 : 1));
      Y[N - i - 1] =
          max(Y[N - i], Y[N - i + C - 1] + (S[N - i - 1] == 'x' ? 0 : 1));
    }
  }
  if (X[N - 1] != K)
    return;

  // for (int i = 0; i < 4; ++i)
  //{
  //	if(X[i] == 1 && Y[i] == K-1)
  // }

  for (int i = 0; i < N; ++i) {
    if (S[i] == 'x')
      continue;

    if ((i == 0 || X[i] > X[i - 1]) && (i == N - 1 || Y[i] > Y[i + 1]))
      cout << i + 1 << endl;
  }
}
int main() {
  ABC161E();
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC161E() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vi X(N), Y(N);
  X[0] = S[0] == 'x' ? 0 : 1;
  X[1] = S[1] == 'x' ? 0 : 1;
  X[2] = S[2] == 'x' ? 0 : 1;
  X[3] = S[3] == 'x' ? 0 : 1;
  Y[N - 1] = S[N - 1] == 'x' ? 0 : 1;
  Y[N - 2] = S[N - 2] == 'x' ? 0 : 1;
  Y[N - 3] = S[N - 3] == 'x' ? 0 : 1;
  Y[N - 4] = S[N - 4] == 'x' ? 0 : 1;
  for (int i = 1; i < 4; ++i) {
    X[i] = max(X[i - 1], X[i]);
    Y[N - i - 1] = max(Y[N - i], Y[N - i - 1]);
  }
  for (int i = 4; i < N; ++i) {
    X[i] = max(X[i - 1], X[i - 4] + (S[i] == 'x' ? 0 : 1));
    Y[N - i - 1] = max(Y[N - i], Y[N - i + 3] + (S[N - i - 1] == 'x' ? 0 : 1));
  }
  if (X[N - 1] != K)
    return;

  // for (int i = 0; i < 4; ++i)
  //{
  //	if(X[i] == 1 && Y[i] == K-1)
  // }

  for (int i = 0; i < N; ++i) {
    if (S[i] == 'x')
      continue;

    if ((i == 0 || X[i] > X[i - 1]) && (i == N - 1 || Y[i] > Y[i + 1]))
      cout << i + 1 << endl;
  }
}

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

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

using namespace std;

#define int long long
#define endl "\\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 998244353;

struct fast_io {
  fast_io() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
  };
} fio;

signed main() {
  cout << fixed << setprecision(10);

  int n, K, C;
  string s;
  vector<int> con1, con2, sum;
  vector<int> hoge1, hoge2;

  cin >> n >> K >> C;
  cin >> s;

  con1.resize(n + 1);
  con2.resize(n + 2);
  sum.resize(n + 1);
  hoge1.resize(n + 2, -1);
  hoge2.resize(n + 2, -1);

  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + (s[i] == 'o');
  }

  for (int i = 1; i <= n; i++) {
    int b = i - C - 1;
    int c = 0;

    if (b >= 0)
      c = con1[b];

    con1[i] = max(con1[i - 1], (int)c + (s[i - 1] == 'o'));
    if (hoge1[con1[i]] == -1)
      hoge1[con1[i]] = i - 1;
  }

  if (con1[n] > K) {
    return 0;
  }

  for (int i = n; i >= 1; i--) {
    int b = i + C + 1;
    int c = 0;

    if (b <= n + 1)
      c = con2[b];

    con2[i] = max(con2[i + 1], (int)c + (s[i - 1] == 'o'));
    if (hoge2[K - con2[i]] == -1)
      hoge2[K - con2[i]] = i - 1;
  }

  // cout<<"con1 n = "<<con1[n]<<endl;

  for (int i = 1, x = 0; i <= K; i++) {
    // cout<<"i = "<<i<<" hoge "<<hoge1[i] <<" "<<hoge2[i-1]<<endl;
    if (hoge1[i] == hoge2[i - 1] && hoge1[i] != -1) {
      cout << hoge1[i] + 1 << endl;
    }
  }

  return 0;
}


Error: 0

Fixed submission:

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

using namespace std;

#define int long long
#define endl "\\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 998244353;

struct fast_io {
  fast_io() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
  };
} fio;

signed main() {
  cout << fixed << setprecision(10);

  int n, K, C;
  string s;
  vector<int> con1, con2, sum;
  vector<int> hoge1, hoge2;

  cin >> n >> K >> C;
  cin >> s;

  con1.resize(n + 1);
  con2.resize(n + 2);
  sum.resize(n + 1);
  hoge1.resize(n + 2, -1);
  hoge2.resize(n + 2, -1);

  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + (s[i] == 'o');
  }

  for (int i = 1; i <= n; i++) {
    int b = i - C - 1;
    int c = 0;

    if (b >= 0)
      c = con1[b];

    con1[i] = max(con1[i - 1], (int)c + (s[i - 1] == 'o'));
    if (hoge1[con1[i]] == -1)
      hoge1[con1[i]] = i - 1;
  }

  for (int i = n; i >= 1; i--) {
    int b = i + C + 1;
    int c = 0;

    if (b <= n + 1)
      c = con2[b];

    con2[i] = max(con2[i + 1], (int)c + (s[i - 1] == 'o'));
    if (hoge2[K - con2[i]] == -1)
      hoge2[K - con2[i]] = i - 1;
  }

  // cout<<"con1 n = "<<con1[n]<<endl;

  for (int i = 1, x = 0; i <= K; i++) {
    // cout<<"i = "<<i<<" hoge "<<hoge1[i] <<" "<<hoge2[i-1]<<endl;
    if (hoge1[i] == hoge2[i - 1] && hoge1[i] != -1) {
      cout << hoge1[i] + 1 << 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++)
using namespace std;
typedef long long ll;
int INF = 1e5;

int main(void) {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vector<int> ball(k);
  vector<int> ball2(k);
  int now = 0;
  int bef = -INF;
  int idx = 0;
  int ballidx = 0;
  map<int, int> mp;
  while (now < k) {
    if (s[idx] == 'o' && idx - bef > c) {
      now++;
      ball[ballidx] = idx;
      ballidx++;
      bef = idx;
    }
    idx++;
  }

  now = 0;
  reverse(s.begin(), s.end());
  idx = 0;
  bef = -INF;
  ballidx--;
  while (now < k) {
    if (s[idx] == 'o' && idx - bef > c) {
      now++;
      ball2[ballidx] = s.size() - 1 - idx;
      ballidx--;
      bef = idx;
    }
    idx++;
  }
  rep(i, k) {
    if (ball[i] == ball2[i])
      cout << ball[i] + 1 << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int INF = 1e6;

int n, k, c;
string s;
map<int, int> work;
int now = 1;
void dfs(int idx, int bef) {
  if (s[idx] == 'x') {
    dfs(idx + 1, bef);
  } else if (idx - bef <= c) {
    dfs(idx + 1, bef);
  } else {
    dfs(idx + 1, bef);
    dfs(idx + 1, idx);
    work[idx]++;
    now *= 2;
  }
}

int main(void) {
  cin >> n >> k >> c;
  cin >> s;
  dfs(0, -INF);
  for (auto p : work) {
    if (p.second == now) {
      cout << p.first + 1 << endl;
    }
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

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

using ll = long long;
using pii = pair<int, int>;

#define vt vector
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fi first
#define se second

signed main() {
  ios::sync_with_stdio(0), cin.tie(0);

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

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

  vt<int> lo(k), hi(k);
  lo[0] = 0, hi.back() = n - 1;
  for (int i = 1, cur = 0; i <= k; i++) {
    auto it = upper_bound(all(pos), cur + c);

    if (i != k)
      lo[i] = cur = *it;
    else if (it != pos.end())
      return 0;
  }
  for (int i = k - 2, cur = n - 1; i >= 0; i--) {
    auto it = lower_bound(all(pos), cur - c);

    hi[i] = cur = *--it;
  }

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


Error: 0

Fixed submission:

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

using ll = long long;
using pii = pair<int, int>;

#define vt vector
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fi first
#define se second

signed main() {
  ios::sync_with_stdio(0), cin.tie(0);

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

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

  vt<int> lo(k), hi(k);
  lo[0] = 0, hi.back() = n - 1;
  for (int i = 1, cur = 0; i <= k; i++) {
    auto it = upper_bound(all(pos), cur + c);
    if (i == k && it != pos.end())
      return 0;

    lo[i] = cur = *it;
  }
  for (int i = k - 2, cur = n - 1; i >= 0; i--) {
    auto it = lower_bound(all(pos), cur - c);

    hi[i] = cur = *--it;
  }

  for (int i = 0; i < k; i++) {
    if (lo[i] == hi[i])
      cout << lo[i] + 1 << '\\n';
  }
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int N, C, K;
char *S;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> K >> C;
  S = new char[N];
  cin >> S;
  //	cout << "N = " << N << ", K = " << K << ", C = " << C << ", S = [" << S
  //<< "]" <<endl;

  // 後詰め pos をxとしたときに、次のセル以降で稼げる最大数
  vector<int> r2l(N, 0);
  int s = 0;
  int d = 0;
  r2l[N - 1] = 0;
  for (int p = N - 1; p > 0; p--) {
    if (d <= 0 && S[p] != 'x') {
      s++;
      d = C + 1;
    }
    r2l[p - 1] = s;
    d--;
  }
  //	cout << "r2l = [";
  //	for (int p = 0; p < N; p++) cout << r2l[p];
  //	cout << "]" << endl;

  // 前詰めしながらカウント
  int p = 0;
  s = 0;
  while (p < N) {
    if (S[p] != 'x') {
      //			cout << "(p,s,r2l[p]) = (" << p << "," << s <<
      //"," << r2l[p] << ")" << endl;
      if (s + r2l[p] < K)
        cout << p + 1 << endl;
      s++;
      p += C + 1;
    } else {
      p++;
    }
  }
}


Error: TLE

Fixed submission:

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

int N, C, K;
char *S;

int subScore(int p, int s) {
  //	cout << "subScore (" << p << "," << s << ")" << endl;
  while (p < N) {
    if (S[p] != 'x') {
      s++;
      //			cout << "         (" << p << "," << s << ")" <<
      //endl;
      if (s >= K)
        break;
      p += C + 1;
    } else {
      p++;
    }
  }
  return s;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> K >> C;
  S = new char[N];
  cin >> S;
  //	cout << "[" << S << "]" <<endl;

  int pos = 0;
  int score = 0;
  while (pos < N) {
    //		cout << "Check " << pos << "," << S[pos] << endl;
    if (S[pos] != 'x') {
      if (subScore(pos + 1, score) < K) {
        cout << pos + 1 << endl;
      }
      score++;
      pos += C + 1;
    } else {
      pos++;
    }
  }
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  vector<int> P, Q, ans;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      P.push_back(i + 1);
      i += c;
    }
  }
  reverse(s.begin(), s.end());
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      Q.push_back(n - i);
      i += c;
    }
  }

  if (P.size() != k || Q.size() != k) {
    return 0;
  }

  else {
    sort(P.begin(), P.end());
    sort(Q.begin(), Q.end());
    int i = 0, j = 0;
    while (i != P.size() && j != Q.size()) {
      if (P[i] > Q[j])
        j++;
      else if (P[i] == Q[j]) {
        ans.push_back(P[i]);
        i++, j++;
      } else
        i++;
    }
    rep(k, ans.size()) cout << ans[k] << endl;
  }
}

Error: -11

Fixed submission:

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

int main() {
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  vector<int> P, Q, ans;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      P.push_back(i + 1);
      i += c;
    }
  }
  reverse(s.begin(), s.end());
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      Q.push_back(n - i);
      i += c;
    }
  }

  if (P.size() != k || Q.size() != k) {
    return 0;
  }

  else {
    sort(P.begin(), P.end());
    sort(Q.begin(), Q.end());
    int i = 0, j = 0;
    while (i != P.size() || j != Q.size()) {
      if (P[i] > Q[j])
        j++;
      else if (P[i] == Q[j]) {
        ans.push_back(P[i]);
        i++, j++;
      } else
        i++;
    }
    rep(k, ans.size()) cout << ans[k] << endl;
  }
}