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

//
//  main.cpp
//  ProgrammingContestChallengeBook2
//
//  Created by Hisaki Kobayashi on 2020/04/04.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>

using namespace std;

int main() {

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

  int normal[200000] = {0};
  int reverse[200000] = {0};

  int cnt = 1;
  for (i = 0; i < N;) {
    if (S[i] == 'x') {
      i++;
      continue;
    } else {
      normal[i] = cnt;
      i += C + 1;
      cnt++;
    }
    if (cnt == K + 1)
      break;
  }
  cnt = K;
  for (i = N - 1; i >= 0;) {
    if (S[i] == 'x') {
      i--;
      continue;
    } else {
      reverse[i] = cnt;
      i = i - (C + 1);
      cnt--;
    }
    if (cnt == 0)
      break;
  }

  for (i = 0; i < N; i++) {
    if (normal[i] == 0 || reverse[i] == 0)
      continue;
    if (normal[i] == reverse[i])
      cout << i + 1 << endl;
  }
}


Error: TLE

Fixed submission:

//
//  main.cpp
//  ProgrammingContestChallengeBook2
//
//  Created by Hisaki Kobayashi on 2020/04/04.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>

using namespace std;

int main() {

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

  int maru_batu[200000] = {-1};
  int j = 0;
  for (i = 0; i < N; i++) {
    if (S[i] == 'x')
      continue;
    maru_batu[j] = i;
    j++;
  }

  for (i = 0; i < j; i++) {
    //        cout << "iの値：" << i << endl;
    int cnt = 0;
    for (k = 0; k < N;) {
      if (k == maru_batu[i]) {
        //                cout << "このk=" << k <<"  なので、○を×にします"<<
        //                endl;
        k++;
        continue;
      }
      if (S[k] == 'o') {
        //                cout << "S["<<k<<"] == Oなので、kをC+1します" << endl;
        k += C + 1;
        cnt++;
      } else {
        k++;
      }
    }
    if (cnt < K)
      cout << maru_batu[i] + 1 << endl;
  }
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

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

ll n, k, c;
string s;

int main() {
  cin >> n >> k >> c;
  cin >> s;
  string sl = s, sr = s;
  ll l[k + 1], r[k + 1], day = 1;
  for (int i = 1; i <= n; i++) {
    if (sl[i - 1] == 'o' && day <= k) {
      l[day] = i;
      i += c;
      day++;
    }
  }
  day = k;
  for (int i = n; i > 0; i--) {
    if (sr[i - 1] == 'o' && day > 0) {
      r[day] = i;
      i -= c;
      day--;
    }
  }
  for (int i = 1; i <= k; i++) {
    if (l[i] == r[i])
      cout << l[i] << endl;
  }
}


Error: 0

Fixed submission:

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

ll n, k, c;
string s;

int main() {
  cin >> n >> k >> c;
  cin >> s;
  string sl = s, sr = s;
  ll l[k + 1], r[k + 1], day = 1;
  for (int i = 1; i <= n; i++) {
    if (sl[i - 1] == 'o') {
      l[day] = i;
      i += c;
      day++;
    }
  }
  day = k;
  for (int i = n; i > 0; i--) {
    if (sr[i - 1] == 'o') {
      r[day] = i;
      i -= c;
      day--;
    }
  }
  for (int i = 1; i <= k; i++) {
    if (l[i] == r[i])
      cout << l[i] << endl;
  }
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdlib>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
struct edge {
  ll to;
  ll cost;
};
using graph = vector<vector<edge>>;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; i++)
#define rep3(i, n, m) for (ll i = n; i >= m; i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second
#define set20 cout << fixed << setprecision(20);
const ll INF = 1e18;
inline void chmax(ll &a, ll b) { a = max(a, b); }
inline void chmin(ll &a, ll b) { a = min(a, b); }
double pi = acos(-1);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  ll n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vector<ll> A(k);
  ll j = 0;
  ll no = 0;
  rep(i, n) {
    if (s[i] == 'o' && no == 0) {
      A[j] = i;
      no = c;
      j++;
    } else {
      if (no > 0)
        no--;
    }
    if (j == k)
      break;
  }
  reverse(s.begin(), s.end());
  vector<ll> B(k);
  j = 0;
  no = 0;
  rep(i, n) {
    if (s[i] == 'o' && no == 0) {
      B[j] = i;
      no = c;
      j++;
    } else {
      if (no > 0)
        no--;
    }
    if (j == k)
      break;
  }

  rep(i, k) {
    if (A[i] + B[k - 1 - i] + 1 == n)
      cout << A[i] + 1 << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdlib>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
struct edge {
  ll to;
  ll cost;
};
using graph = vector<vector<edge>>;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; i++)
#define rep3(i, n, m) for (ll i = n; i >= m; i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second
#define set20 cout << fixed << setprecision(20);
const ll INF = 1e18;
inline void chmax(ll &a, ll b) { a = max(a, b); }
inline void chmin(ll &a, ll b) { a = min(a, b); }
double pi = acos(-1);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  ll n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vector<ll> A(k);
  ll j = 0;
  ll no = 0;
  rep(i, n) {
    if (s[i] == 'o' && no == 0) {
      A[j] = i;
      no = c;
      j++;
    } else {
      if (no > 0)
        no--;
    }
    if (j == k + 1)
      break;
  }
  reverse(s.begin(), s.end());
  vector<ll> B(k);
  j = 0;
  no = 0;
  rep(i, n) {
    if (s[i] == 'o' && no == 0) {
      B[j] = i;
      no = c;
      j++;
    } else {
      if (no > 0)
        no--;
    }
    if (j == k + 1)
      break;
  }

  rep(i, k) {
    if (A[i] + B[k - 1 - i] + 1 == n)
      cout << A[i] + 1 << endl;
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

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

vector<int64_t> memo;

int64_t greedy(const string &s, int64_t index, int64_t C) {
  if (index >= s.size()) {
    return 0;
  }
  if (memo[index] != -1) {
    return memo[index];
  }

  for (int64_t i = index; i < s.size(); i++) {
    if (s[i] == 'o') {
      return memo[index] = (1 + greedy(s, i + C + 1, C));
    }
  }

  return memo[index] = 0;
}

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

  cin >> N >> K >> C >> S;
  memo.resize(N + 1, -1);

  vector<int64_t> ans;
  for (int64_t i = 0; i < S.size(); i++) {
    if (S[i] == 'x') {
      continue;
    }

    // S[i] == 'o'
    // ここが必須かどうか
    // S[i] = 'x'として判定してみる
    // ダメなら必須
    int64_t num = greedy(S, i + 1, C);
    if (num < K) {
      ans.push_back(i + 1);
    }

    // ここをオフにしない場合、絶対に選ぶのが得
    K--;
    i += C;
  }

  for (int64_t value : ans) {
    cout << value << endl;
  }
}

Error: 0

Fixed submission:

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

vector<int64_t> memo;

int64_t greedy(const string &s, int64_t index, int64_t C) {
  if (index >= s.size() || memo[index] != -1) {
    return memo[index];
  }

  for (int64_t i = index; i < s.size(); i++) {
    if (s[i] == 'o') {
      return memo[index] = (1 + greedy(s, i + C + 1, C));
    }
  }

  return memo[index] = 0;
}

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

  cin >> N >> K >> C >> S;
  memo.resize(N + 1, -1);

  vector<int64_t> ans;
  for (int64_t i = 0; i < S.size(); i++) {
    if (S[i] == 'x') {
      continue;
    }

    // S[i] == 'o'
    // ここが必須かどうか
    // S[i] = 'x'として判定してみる
    // ダメなら必須
    int64_t num = greedy(S, i + 1, C);
    if (num < K) {
      ans.push_back(i + 1);
    }

    // ここをオフにしない場合、絶対に選ぶのが得
    K--;
    i += C;
  }

  for (int64_t value : ans) {
    cout << value << endl;
  }
}
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;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  auto getPositions = [&]() {
    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 = getPositions();
  reverse(s.begin(), s.end());
  r = getPositions();
  rep(i, k) r[i] = n - 1 - r[i];
  reverse(s.begin(), s.end());

  vector<int> lastL(n + 1, -1);
  rep(i, k) lastL[l[i] + 1] = i;
  rep(i, n) {
    if (lastL[i + 1] == -1)
      lastL[i + 1] = lastL[i];
  }
  vector<int> lastR(n + 1, -1);
  rep(i, k) lastR[r[i]] = i;
  for (int i = n - 1; i >= 0; --i) {
    if (lastR[i] == -1)
      lastR[i] = lastR[i + 1];
  }

  rep(i, n) {
    if (s[i] == 'x')
      continue;
    int li = lastL[i];
    int ri = lastR[i + 1];
    int cnt = 0;
    if (li != -1)
      cnt += li + 1;
    if (ri != -1)
      cnt += ri + 1;
    if (li != -1 && ri != -1 && r[ri] - l[li] <= c) {
      --cnt;
    }
    if (cnt >= k)
      continue;
    printf("%d\\n", i + 1);
  }
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using p = pair<int, int>;
const long long INF = numeric_limits<long long>::max();

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

  auto getPositions = [&]() {
    vector<int> res;
    for (int i = 0; i < n && res.size() < K; i++) {
      if (S[i] == 'o') {
        res.push_back(i);
        i += C + 1;
      } else {
        ++i;
      }
    }
    return res;
  };
  vector<int> l, r;
  l = getPositions();
  reverse(S.begin(), S.end());
  r = getPositions();
  REP(i, K) r[i] = n - 1 - r[i];
  reverse(S.begin(), S.end());
  // 1つまえの'o'の位置
  vector<int> lastL(n + 1, -1);
  REP(i, K) lastL[l[i] + 1] = i;
  REP(i, n) {
    if (lastL[i + 1] == -1)
      lastL[i + 1] = lastL[i];
  }
  vector<int> lastR(n + 1, -1);
  REP(i, K) lastR[l[i]] = i;
  for (int i = n - 1; i >= -1; --i) {
    if (lastR[i] == -1)
      lastR[i] = lastR[i + 1];
  }

  REP(i, n) {
    if (S[i] == 'x')
      continue;
    int li = lastL[i];
    int ri = lastR[i + 1];
    int cnt = 0;
    if (li != -1)
      cnt += li + 1;
    if (ri != -1)
      cnt += ri + 1;
    if (li != -1 && ri != -1 && r[ri] - l[li] <= C) {
      --cnt;
    }
    if (cnt >= K)
      continue;
    printf("%d\\n", i + 1);
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < n; i++)

int main() {
  int64_t n, k, c;
  cin >> n >> k >> c;
  string str;
  cin >> str;
  vector<int64_t> hataraku_L(n, 0);
  vector<int64_t> hataraku_R(n, 0);
  int64_t temp = 0;
  int64_t temp1 = n - 1;
  rep(i, k) {
    for (int64_t j = temp; j < n; j++) {
      if (str[j] == 'o') {
        hataraku_L[j] = i + 1;
        temp = j + c + 1;
        break;
      }
    }
    for (int64_t j = temp1; j >= 0; j--) {
      if (str[j] == 'o') {
        hataraku_R[j] = k - i;
        temp1 = j - c - 1;
        break;
      }
    }
  }

  rep(i, n) {

    if (hataraku_L[i] == hataraku_R[i] && hataraku_R[i] != 0) {
      cout << i + 1 << endl;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string str;
  cin >> str;
  vector<int> hataraku_L(n, 0);
  vector<int> hataraku_R(n, 0);
  vector<vector<bool>> ans(n, vector<bool>(2, false));
  vector<int> final_ans;
  int temp1 = 0;
  int temp2 = n - 1;
  rep(i, k) {
    for (int j = temp1; j < n; j++) {
      if (str[j] == 'o') {
        hataraku_L[j] = i + 1;
        temp1 = j + c;
        ans[j][0] = true;
        break;
      }
    }
    for (int j = temp2; j >= 0; j--) {
      if (str[j] == 'o') {
        hataraku_R[j] = i + 1;
        temp2 = j - c;
        ans[j][1] = true;
        break;
      }
    }
  }
  rep(i, n) {
    if (ans[i][0] && ans[i][1]) {
      final_ans.push_back(i + 1);
    }
  }
  for (int i = 0; i < final_ans.size() - 1; i++) {
    cout << final_ans[i] << " ";
  }
  cout << final_ans.back() << endl;

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

#include <bits/stdc++.h>
const int N = 400005;
using namespace std;
int k, n, c, ans, l[N], r[N];
string s;
int main() {
  cin >> n >> k >> c >> s;
  int i = 1, kk = 0;
  while (kk < k) {
    if (s[i - 1] == 'o')
      kk++, l[kk] = i, i += c;
    i++;
  }
  i = n, kk = k;
  while (kk > 0) {
    if (s[i - 1] == 'o')
      r[kk] = i, kk--, i -= c;
    i--;
  }
  for (int j = 1; j <= k; j++)
    if (r[j] == l[j] && r[j] != 0)
      cout << l[j] << endl;
  return 0;
}
// 68871358
// 76140264
// 25446011
// 200841159
// 914174775

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
int k, n, c, ans, l[N], r[N];
string s;
int main() {
  cin >> n >> k >> c >> s;
  int i = 1, kk = 0;
  while (kk <= k) {
    if (s[i - 1] == 'o')
      kk++, l[kk] = i, i += c;
    i++;
  }
  i = n, kk = k;
  while (kk > 0) {
    if (s[i - 1] == 'o')
      r[kk] = i, kk--, i -= c;
    i--;
  }
  for (int j = 1; j <= k; j++)
    if (r[j] == l[j] && r[j] != 0)
      cout << l[j] << endl;
  return 0;
}
// 68871358
// 76140264
// 25446011
// 200841159
// 914174775
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
  int N, K, C;
  string S;
  cin >> N >> K >> C >> S;
  vector<int> from_front, from_back;

  REP(i, N) {
    if (S[i] == 'o') {
      from_front.push_back(i);
      i += C;
    }
    if (from_front.size() == K)
      break;
  }
  RREP(i, N) {
    if (S[i] == 'o') {
      from_back.push_back(i);
      i -= C;
    }
    if (from_back.size() == K)
      break;
  }
  reverse(ALL(from_back));
  REP(i, from_front.size()) {
    if (from_front[i] == from_back[i])
      cout << from_front[i] + 1 << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int N, K, C;
string S;

vector<int> get_work_days() {
  vector<int> ret;
  RREP(i, N) {
    if (S[i] == 'o') {
      ret.push_back(i);
      i -= C;
    }
    if (ret.size() == K)
      break;
  }
  return ret;
}

int get_work_days_size() {
  int cnt = 0;
  RREP(i, N) {
    if (S[i] == 'o') {
      cnt++;
      i -= C;
    }
    if (cnt == K)
      break;
  }
  return cnt;
}

int main() {
  cin >> N >> K >> C >> S;
  vector<int> days = get_work_days(), must_days;
  for (int day : days) {
    S[day] = 'x';
    if (days.size() != get_work_days_size()) {
      must_days.push_back(day);
    }
    S[day] = 'o';
  }
  RREP(i, must_days.size()) cout << must_days[i] + 1 << endl;
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main(int, char **) {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  queue<int> que;
  stack<int> stk;
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'o') {
      que.push(i + 1);
      stk.push(i + 1);
    }
  }
  vector<int> l;
  int cnt = 0;
  int lp = -2 * n;

  while (cnt < k) {
    int now = que.front();
    que.pop();
    if (now - lp > c) {
      l.push_back(now);
      cnt++;
      lp = now;
    }
  }

  vector<int> r;
  cnt = 0;
  int rp = 3 * n;
  while (cnt < k) {
    int now = stk.top();
    stk.pop();
    if (rp - now > c) {
      r.push_back(now);
      cnt++;
      rp = now;
    }
  }
  for (int i = 0; i < k; i++) {
    int a = l.at(i);
    int b = r.at(k - i - 1);
    if (a == b)
      cout << a << endl;
  }

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main(int, char **) {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  queue<int> que;
  stack<int> stk;
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'o') {
      que.push(i + 1);
      stk.push(i + 1);
    }
  }
  vector<int> l;
  int cnt = 0;
  int lp = -n;

  while (cnt < k) {
    int now = que.front();
    que.pop();
    // cout << now - lp << endl;
    if (now - lp > c) {
      l.push_back(now);
      cnt++;
      // cout << now << endl;
      lp = now;
    }
  }
  vector<int> r;
  int rp = 2 * n;
  cnt = 0;
  while (cnt < k) {
    int now = stk.top();
    stk.pop();
    if (rp - now > c) {
      r.push_back(now);
      cnt++;
      // cout << now << endl;
      rp = now;
    }
  }
  for (int i = 0; i < k; i++) {
    int a = l.at(i);
    int b = r.at(k - i - 1);
    if (a == b)
      cout << a << endl;
  }

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

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

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int n, k, c;
char s[200005];
int l[100005], r[100005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k >> c;
  for (int i = 1; i <= n; i++)
    cin >> s[i];
  int cnt = 1, nxt = 1;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'o' && i >= nxt) {
      l[cnt++] = i;
      nxt = i + c + 1;
    }
  }
  cnt = k, nxt = n;
  for (int i = n; i >= 1; i--) {
    if (s[i] == 'o' && i <= nxt) {
      r[cnt--] = i;
      nxt = i - c - 1;
    }
  }
  for (int i = 1; i <= k; i++)
    if (l[i] == r[i])
      cout << l[i] << endl;
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) { // 発見できたとき
    return 1;
  } else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int n, k, c, countt, countu;
  string s, t, u;
  cin >> n >> k >> c >> s;
  t = s;
  u = s;
  countt = 0;
  countu = 0;
  vector<int> anst, ansu, ans;
  for (int i = 0; i < n && countt < k; i++) {
    if (t.at(i) == 'o') {
      for (int j = i; j - i <= c && j < n; j++) {
        t.at(j) = 'x';
      }
      anst.push_back(i);
      i += c;
      countt++;
    }
  }
  for (int i = n - 1; i >= 0 && countu < k; i -= 1) {
    if (u.at(i) == 'o') {
      for (int j = i; i - j <= c && j >= 0; j -= 1) {
        u.at(j) = 'x';
      }
      ansu.push_back(i);
      i -= c;
      countu++;
    }
  }
  if (t.find('o') != -1 || u.find('o') != -1) {
    cout << endl;
  } else {
    int i = 0;
    int j = k - 1;
    while (i < k && j >= 0) {
      if (anst.at(i) == ansu.at(j)) {
        printf("%d\\n", anst.at(i) + 1);
        i++;
        j -= 1;
      } else if (anst.at(i) > ansu.at(j)) {
        j -= 1;
      } else {
        i++;
      }
    }
  }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) { // 発見できたとき
    return 1;
  } else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int n, k, c, countt, countu;
  string s, t, u;
  cin >> n >> k >> c >> s;
  t = s;
  u = s;
  countt = 0;
  countu = 0;
  vector<int> anst, ansu, ans;
  for (int i = 0; i < n && countt < k; i++) {
    if (t.at(i) == 'o') {
      if (i + c >= n - 1) {
        anst.push_back(i);
        t.replace(n - 1 - c, c + 1, c + 1, 'x');
        countt++;
        break;
      }
      t.replace(i, c + 1, c + 1, 'x');
      anst.push_back(i);
      i += c;
      countt++;
    }
  }
  for (int i = n - 1; i >= 0 && countu < k; i -= 1) {
    if (u.at(i) == 'o') {
      if (i - c <= -1) {
        ansu.push_back(i);
        u.replace(0, c + 1, c + 1, 'x');
        countt++;
        break;
      }
      u.replace(i - c, c + 1, c + 1, 'x');
      ansu.push_back(i);
      i -= c;
      countu++;
    }
  }
  if (t.find('o') != -1 || u.find('o') != -1) {
    cout << endl;
  } else {
    for (int i = 0; i < anst.size(); i++) {
      if (vector_finder(ansu, anst.at(i)) == 1) {
        printf("%d\\n", anst.at(i) + 1);
      }
    }
  }
}
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))
using ll = long long;
using namespace std;

int l[201010], r[201010];

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

  int cur = 1;
  for (int i = 0; i < N; ++i) {
    if (S[i] == 'o') {
      l[i] = cur++;
      i += C;
    }
    if (cur > K)
      break;
  }

  cur = K;
  for (int i = N - 1; i >= 0; --i) {
    if (S[i] == 'o') {
      r[i] = cur--;
      i -= C;
    }
    if (cur < 0)
      break;
  }

  for (int i = 0; i < N; ++i) {
    // cout << l[i] << ", " << r[i] << endl;
    if (l[i] > 0 and l[i] == r[i]) {
      cout << i + 1 << endl;
    }
  }
}


Error: 0

Fixed submission:

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

int l[101010], r[101010];

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

  int cur = 1;
  for (int i = 0; i < N; ++i) {
    if (S[i] == 'o') {
      l[i] = cur++;
      i += C;
    }
    if (cur > K)
      break;
  }

  cur = K;
  for (int i = N - 1; i >= 0; --i) {
    if (S[i] == 'o') {
      r[i] = cur--;
      i -= C;
    }
    if (cur < 0)
      break;
  }

  for (int i = 0; i < N; ++i) {
    // cout << l[i] << ", " << r[i] << endl;
    if (l[i] > 0 and l[i] == r[i]) {
      cout << i + 1 << endl;
    }
  }
}