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

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

void show(vector<int> &s) {
  for (auto x : s) {
    cout << x << " ";
  }
  cout << endl;
}

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

  string s;
  cin >> s;

  vector<int> workable1;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      workable1.emplace_back(i + 1);
    }
  }
  auto workable2 = workable1;
  reverse(workable2.begin(), workable2.end());
  for (int i = 0; i < workable2.size(); i++) {
    workable2[i] *= -1;
  }

  int day = -1;
  vector<int> work1, work2;

  for (int i = 0; i < k; i++) {
    day = *upper_bound(workable1.begin(), workable1.end(), day);
    work1.push_back(day);
    day += c;
  }

  day = workable2[0] - 100;
  for (int i = 0; i < k; i++) {
    day = *upper_bound(workable2.begin(), workable2.end(), day);
    work2.push_back(abs(day));
    day += c;
  }
  sort(work2.begin(), work2.end());

  // show(work1);
  // show(work2);

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

  return 0;
}


Error: -6
munmap_chunk(): invalid pointer


Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

void show(vector<int> &s) {
  for (auto x : s) {
    cout << x << " ";
  }
  cout << endl;
}

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

  string s;
  cin >> s;

  vector<int> workable1;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      workable1.emplace_back(i + 1);
    }
  }
  auto workable2 = workable1;
  reverse(workable2.begin(), workable2.end());
  for (int i = 0; i < n; i++) {
    workable2[i] *= -1;
  }

  int day = -1;
  vector<int> work1, work2;

  for (int i = 0; i < k; i++) {
    day = *upper_bound(workable1.begin(), workable1.end(), day);
    work1.push_back(day);
    day += c;
  }

  day = workable2[0] - 100;
  for (int i = 0; i < k; i++) {
    day = *upper_bound(workable2.begin(), workable2.end(), day);
    work2.push_back(abs(day));
    day += c;
  }
  sort(work2.begin(), work2.end());

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

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

/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for (int V = S; V < E; V++)
#define ford(V, S, E) for (int V = S; V >= E; V--)
#define fore(E, X) for (auto &E : X)
#define println(X) cout << X << endl
#define printe(X)                                                              \\
  for (auto &E : X)                                                            \\
    cout << E << " ";                                                          \\
  cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int L[200001], R[200001];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  int wd = 0, cd = 0;
  forl(i, 0, n) {
    if (cd) {
      cd--;
      continue;
    }
    if (s[i] != 'o')
      continue;
    L[wd++] = i;
    cd = c;
  }
  wd = k - 1, cd = 0;
  ford(i, n - 1, 0) {
    if (cd) {
      cd--;
      continue;
    }
    if (s[i] != 'o' or wd < 0)
      continue;
    R[wd--] = i;
    cd = c;
  }
  vector<int> ans;
  forl(i, 0, k) {
    if (R[i] == L[i])
      ans.push_back(R[i] + 1);
  }
  printe(ans);
}


Error: WA

Fixed submission:

/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for (int V = S; V < E; V++)
#define ford(V, S, E) for (int V = S; V >= E; V--)
#define fore(E, X) for (auto &E : X)
#define println(X) cout << X << endl
#define printe(X)                                                              \\
  for (auto &E : X)                                                            \\
    cout << E << " ";                                                          \\
  cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int L[200001], R[200001];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  int wd = 0, cd = 0;
  forl(i, 0, n) {
    if (cd) {
      cd--;
      continue;
    }
    if (s[i] != 'o')
      continue;
    L[wd++] = i;
    cd = c;
  }
  wd = k - 1, cd = 0;
  ford(i, n - 1, 0) {
    if (cd) {
      cd--;
      continue;
    }
    if (s[i] != 'o')
      continue;
    R[wd--] = i;
    cd = c;
  }
  vector<int> ans;
  forl(i, 0, k) {
    if (R[i] == L[i])
      ans.push_back(R[i] + 1);
  }
  printe(ans);
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <set>
using namespace std;
const int MAXN = 200005;
int n, k, c;
char s[MAXN];

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

  set<int> s1, s2;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'o')
      s1.insert(i), i += c;
  }

  for (int j = n; j >= 1; j--) {
    if (s[j] == 'o')
      s2.insert(j), j -= c;
  }

  if (s1.size() > k || s2.size() > k)
    return 0;
  for (int v : s1) {
    if (s2.count(v))
      cout << v << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
const int MAXN = 200005;
int n, k, c;
char s[MAXN];

int judge() {
  int cnt = 0;
  for (int i = 1; i <= n;) {
    if (s[i] == 'o') {
      i += c + 1, cnt++;
      if (cnt >= k)
        return 1;
    } else
      i++;
  }

  return cnt >= k;
}

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

  for (int i = 1; i <= n; i++) {
    if (s[i] == 'o') {
      s[i] = 'x';
      if (!judge())
        cout << i << endl;
      s[i] = 'o';
    }
  }
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
const int inf = 1 << 30;
const ll linf = 1e18;
template <class T> void chmin(T &x, T y) {
  if (x > y)
    x = y;
}
template <class T> void chmax(T &x, T y) {
  if (x < y)
    x = y;
}

int N, K, C;
string S;
int L[200010];
int R[200010];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> K >> C >> S;

  int cnt = 0;
  int idx = 0;
  while (cnt < K && idx < N) {
    if (S[idx] == 'o') {
      cnt++;
      L[cnt] = idx;
      idx += C;
    }
    idx++;
  }

  cnt = K + 1;
  idx = N - 1;
  while (cnt > 0 && idx >= 0) {
    if (S[idx] == 'o') {
      cnt--;
      R[cnt] = idx;
      idx -= C;
    }
    idx--;
  }
  for (int i = 1; i <= K; i++) {
    if (L[i] == R[i]) {
      cout << L[i] + 1 << endl;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
const int inf = 1 << 30;
const ll linf = 1e18;
template <class T> void chmin(T &x, T y) {
  if (x > y)
    x = y;
}
template <class T> void chmax(T &x, T y) {
  if (x < y)
    x = y;
}

int N, K, C;
string S;
int L[200010];
int R[200010];
int f[200010], b[200010];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> K >> C >> S;

  int cnt = 0;
  int idx = 0;
  while (cnt < K) {
    if (S[idx] == 'o') {
      cnt++;
      L[cnt] = idx;
      idx += C;
    }
    idx++;
  }

  cnt = K + 1;
  idx = N - 1;
  while (cnt > 0) {
    if (S[idx] == 'o') {
      cnt--;
      R[cnt] = idx;
      idx -= C;
    }
    idx--;
  }

  for (int i = 1; i <= K; i++) {
    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 pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
int n, a, b;
string s;
int early[200005], late[200005];
signed main() {
  cin >> n >> a >> b >> s;
  int y = 0;
  for (int i = 0; i < a; i++) {
    for (int j = y;; j++) {
      if (s[j] == 'o') {
        early[i] = j;
        break;
      }
    }
    y = early[i] + b + 1;
  }
  y = n - 1;
  for (int i = a - 1; i >= 0; i--) {
    for (int j = y;; j--) {
      if (s[j] == 'o') {
        late[i] = j;
        break;
      }
    }
    y = late[i] - b - 1;
  }
  for (int i = 0; i < a; i++) {
    if (early[i] == late[i]) {
      cout << late[i] + 1 << endl;
    }
  }
  re 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
int n, a, b;
string s;
vector<int> t(200005, 1);
void ans(vector<int> v) {
  if (sz(v) == a) {
    for (int i = 0; i < n; i++) {
      if (find(all(v), i) == v.end())
        t[i] = 0;
    }
  } else if (v[sz(v) - 1] + (a - sz(v)) * (b + 1) < n) {
    for (int i = v[sz(v) - 1] + b + 1; i < n; i++) {
      if (s[i] == 'x')
        continue;
      vector<int> vv = v;
      vv.pb(i);
      ans(vv);
    }
  }
  re;
}
signed main() {
  cin >> n >> a >> b >> s;
  for (int i = 0; i < n; i++) {
    if (s[i])
      ans(vector<int>(1, i));
  }
  for (int i = 0; i < n; i++) {
    if (t[i]) {
      cout << i + 1 << endl;
    }
  }
  re 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;
int N, K, C;
string S;
int main(void) {
  cin >> N >> K >> C >> S;
  int work[2][K];
  memset(work, 0, sizeof work);
  for (int day = 0, cnt = 0; day < N && cnt < K; day++)
    if (S[day] == 'o')
      work[0][cnt++] = day, day += C;
  for (int day = N - 1, cnt = 0; day >= 0 && cnt < K; day--)
    if (S[day] == 'o')
      work[1][K - 1 - cnt++] = day, day -= C;
  for (int i = 0; i < K; i++)
    if (work[0][i] == work[1][i])
      cout << work[0][i] + 1 << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;
int N, K, C;
string S;
int main(void) {
  cin >> N >> K >> C >> S;
  int work[2][K];
  memset(work, 0, sizeof work);
  for (int day = 0, cnt = 0; day < N; day++)
    if (S[day] == 'o')
      work[0][cnt++] = day, day += C;
  for (int day = N - 1, cnt = 0; day >= 0; day--)
    if (S[day] == 'o')
      work[1][K - 1 - cnt++] = day, day -= C;
  for (int i = 0; i < K; i++)
    if (work[0][i] == work[1][i])
      cout << work[0][i] + 1 << endl;
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define F first
#define S second

#define ONLINE_JUDGE 1

using namespace std;

const int mod = 1e9 + 7;
const int MAX = 100001;

void pr(vector<int> v) {
  for (int x : v) {
    cout << x << " ";
  }
  cout << "\\n";
}

void solve() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vector<int> lf(n);
  vector<int> rt(n);
  int t = 1;
  int p = -MAX;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      int d = i - p;
      if (d > c) {
        lf[i] = t++;
        p = i;
      }
      if (t > k)
        break;
    }
  }
  reverse(s.begin(), s.end());
  t = k;
  p = -MAX;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      int d = i - p;
      if (d > c) {
        rt[i] = t--;
        p = i;
      }
      // if(t > k) break;
    }
  }
  reverse(rt.begin(), rt.end());
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (rt[i] == lf[i] && rt[i] > 0) {
      cout << i + 1 << "\\n";
    }
  }
}
int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int t = 1;
  // cin >> t;
  while (t--)
    solve();
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define F first
#define S second

// #define ONLINE_JUDGE 1

using namespace std;

const int mod = 1e9 + 7;
const int MAX = 100001;

void pr(vector<int> v) {
  for (int x : v) {
    cout << x << " ";
  }
  cout << "\\n";
}

void solve() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vector<int> lf(n);
  vector<int> rt(n);
  int t = 1;
  int p = -MAX;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      int d = i - p;
      if (d > c) {
        lf[i] = t++;
        p = i;
      }
      if (t > k)
        break;
    }
  }
  reverse(s.begin(), s.end());
  t = k;
  p = -MAX;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      int d = i - p;
      if (d > c) {
        rt[i] = t--;
        p = i;
      }
      // if(t > k) break;
    }
  }
  reverse(rt.begin(), rt.end());
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (rt[i] == lf[i] && rt[i] > 0) {
      cout << i + 1 << "\\n";
    }
  }
}
int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int t = 1;
  // cin >> t;
  while (t--)
    solve();
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

char s[200010];
int a[200010], l[200010], r[200010], b[200010];
int n, k, c;

int main() {
  scanf("%d%d%d", &n, &k, &c);
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'x')
      a[i + 1] = 0;
    else
      a[i + 1] = 1;
  }
  for (int i = 1; i <= c + 1; i++)
    l[i] = a[i];
  for (int i = c + 2; i <= n; i++) {
    l[i] = l[i - 1];
    if (a[i] == 1) {
      l[i] = max(l[i], l[i - c - 1] + 1);
    }
  }
  int ans = l[n];
  if (ans > k)
    return 0;
  for (int i = n; i >= n - c - 1 && i >= 1; i--)
    r[i] = ans;
  for (int i = n - c - 1; i >= 1; i--) {
    r[i] = r[i + 1];
    if (a[i] == 1) {
      r[i] = min(r[i], r[i + c + 1] - 1);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (l[i] == r[i]) {
      b[l[i]]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (l[i] == r[i]) {
      if (b[l[i]] == 1)
        printf("%d\\n", i);
    }
  }
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

char s[100010];
int a[100010], l[100010], r[100010], b[100010];
int n, k, c;

int main() {
  scanf("%d%d%d", &n, &k, &c);
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'x')
      a[i + 1] = 0;
    else
      a[i + 1] = 1;
  }
  for (int i = 1; i <= c + 1; i++)
    l[i] = a[i];
  for (int i = c + 2; i <= n; i++) {
    l[i] = l[i - 1];
    if (a[i] == 1) {
      l[i] = max(l[i], l[i - c - 1] + 1);
    }
  }
  int ans = l[n];
  if (ans > k)
    return 0;
  for (int i = n; i >= n - c - 1 && i >= 1; i--)
    r[i] = ans;
  for (int i = n - c - 1; i >= 1; i--) {
    r[i] = r[i + 1];
    if (a[i] == 1) {
      r[i] = min(r[i], r[i + c + 1] - 1);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (l[i] == r[i]) {
      b[l[i]]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (l[i] == r[i]) {
      if (b[l[i]] == 1)
        printf("%d\\n", i);
    }
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main(void) {
  int N, K, C, i, j, a, b, c;
  string S;
  cin >> N >> K >> C;
  cin >> S;
  int arr[N];
  j = 0;
  for (i = 0; i < N; i++) {
    if (S[i] == 'o') {
      arr[j++] = i + 1;
    }
  }
  int L[K], R[K];
  a = j - 1;
  b = K - 1;
  c = arr[a];
  L[b] = c;
  while (a >= 0) {
    if (c - C > arr[a]) {
      b--;
      c = arr[a];
      L[b] = c;
      if (b == 0) {
        break;
      }
    }
    a--;
  }

  a = 0;
  b = 0;
  c = arr[a];
  R[b] = c;
  while (a < j) {
    if (c + C < arr[a]) {
      b++;
      c = arr[a];
      R[b] = c;
      if (b == K - 1) {
        break;
      }
    }
    a++;
  }

  /*
  cerr << N <<" "<< K <<" "<< C <<endl;
  cerr << S << endl;
  for(i = 0; i < j; i++)
  {
      cerr << arr[i] << " ";
  }
  cerr << endl;
  for(i = 0; i < K; i++)
  {
      cerr << L[i] << " ";
  }
  cerr << endl;
  for(i = 0; i < K; i++)
  {
      cerr << R[i] << " ";
  }
  cerr << endl;
  */
  for (i = 0; i < K; i++) {
    if (L[i] == R[i]) {
      cout << L[i] << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main(void) {
  int N, K, C, i, j, a, b, c;
  string S;
  cin >> N >> K >> C;
  cin >> S;
  int arr[N];
  j = 0;
  for (i = 0; i < N; i++) {
    if (S[i] == 'o') {
      arr[j++] = i + 1;
    }
  }
  int L[K], R[K];
  for (i = 0; i < K; i++) {
    a = j - 1;
    b = K - 1;
    c = arr[a];
    while ((a >= 0) && (b != i)) {
      if (c - C > arr[a]) {
        b--;
        c = arr[a];
      }
      a--;
    }
    L[b] = c;
  }
  for (i = 0; i < K; i++) {
    a = 0;
    b = 0;
    c = arr[a];
    while ((a < j) && (b != i)) {
      if (c + C < arr[a]) {
        b++;
        c = arr[a];
      }
      a++;
    }
    R[b] = c;
  }
  /*
  cerr << N <<" "<< K <<" "<< C <<endl;
  cerr << S << endl;
  for(i = 0; i < j; i++)
  {
      cerr << arr[i] << " ";
  }
  cerr << endl;
  for(i = 0; i < K; i++)
  {
      cerr << L[i] << " ";
  }
  cerr << endl;
  for(i = 0; i < K; i++)
  {
      cerr << R[i] << " ";
  }
  cerr << endl;
  */
  for (i = 0; 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>
#include <iostream>
#include <vector>
using namespace std;
#define MAX 200000

int main(int, char **) {
  int n, k, c;
  string s;

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

  int l[MAX], r[MAX];
  int intvl, count;
  intvl = c;
  count = 0;
  for (int i = 0; count < k && i < n; i++) {
    if (s[i] == 'x' || intvl < c)
      intvl++;
    else {
      l[count] = i;
      intvl = 0;
      count++;
    }
  }
  intvl = c;
  count = 0;
  for (int i = n - 1; count < k && i >= 0; i--) {
    if (s[i] == 'x' || intvl < c)
      intvl++;
    else {
      r[k - count - 1] = i;
      intvl = 0;
      count++;
    }
  }
  for (int i = 0; i < k; i++) {
    if (l[i] == r[i])
      cout << l[i] + 1 << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

vector<bool> work_g;

void workCheck(vector<bool> work, int n, int skip, int start, int remain) {
  if (remain == 0) {
    for (int i = start + 1; i < n; i++)
      work[i] = false;
    for (int i = 0; i < n; i++)
      if (!work[i])
        work_g[i] = false;
    return;
  }

  for (int i = start + 1; i <= start + skip; i++)
    work[i] = false;
  for (int i = start + skip + 1; i < n; i++)
    if (work[i]) {
      workCheck(work, n, skip, i, remain - 1);
      work[i] = false;
    }
}

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

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

  vector<bool> work(n, true);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'x')
      work[i] = false;
  }

  work_g = work;
  for (int i = 0; i < n; i++)
    if (work[i]) {
      workCheck(work, n, c, i, k - 1);
      work[i] = false;
    }

  for (int i = 0; i < n; i++)
    if (work_g[i])
      cout << i + 1 << endl;

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits.h>
#include <numeric>
#include <vector>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

struct DP {
  int prev_workday;
  int daycount;
};
using vdp = vector<DP>;

vdp left_schedule(int N, int K, int C, const string &S) {
  int k, count = 0, skip = 0;
  vdp work(N);
  for (int i = 0; i < N; i++) {
    if (skip <= 0 && S[i] == 'o') {
      count++;
      k = i;
      skip = C;
    } else if (skip > 0) {
      --skip;
    }
    work[i].daycount = count;
    work[i].prev_workday = k;
  }
  return work;
}

vdp right_schedule(int N, int K, int C, const string &S) {
  int k, count = 0, skip = 0;
  vdp work(N);
  for (int i = N - 1; i >= 0; i--) {
    if (skip <= 0 && S[i] == 'o') {
      count++;
      k = i;
      skip = C;
    } else if (skip > 0) {
      --skip;
    }
    work[i].daycount = count;
    work[i].prev_workday = k;
  }
  return work;
}

bool is_valid(const vdp &min_sche, const vdp &max_sche, int N, int K, int C,
              int i) {
  int skip = C + 1;
  if (i > 0 && i < N - 1) {
    skip = max_sche[i + 1].prev_workday - min_sche[i - 1].prev_workday;
  }

  int left_daycount = 0, right_daycount = 0;
  if (i > 0)
    left_daycount = min_sche[i - 1].daycount;
  if (i < N - 1)
    right_daycount = max_sche[i + 1].daycount;
  bool valid;
  if (skip <= C) {
    valid = (left_daycount + right_daycount >= K + 1);
  } else {
    valid = (left_daycount + right_daycount >= K);
  }
  return valid;
}

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

  vdp min_sche = left_schedule(N, K, C, S);
  vdp max_sche = right_schedule(N, K, C, S);

  for (int i = 0; i < N; i++) {
    if (!is_valid(min_sche, max_sche, N, K, C, i)) {
      cout << (i + 1) << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits.h>
#include <numeric>
#include <vector>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

vi search1sche(int N, int K, int C, const string &S) {
  int k = 0;
  vi work(K);
  for (int i = 0; i < N && k < K; i++) {
    if (S[i] == 'o') {
      work[k++] = i;
      i += C;
    }
  }
  if (k < K) {
    return vi(0);
  } else {
    return work;
  }
}

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

  vi work = search1sche(N, K, C, S);

  for (int w : work) {
    string cS = S;
    cS[w] = 'x';
    vi csche = search1sche(N, K, C, cS);
    if (csche.size() == 0) {
      cout << (w + 1) << endl;
    }
  }
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int maxn = 2e5 + 5;
bool valid[maxn];
int l_minn[maxn], r_minn[maxn];
int main() {
  int n, k, c;
  scanf("%d%d%d", &n, &k, &c);
  char s;
  scanf("%c", &s);
  for (int i = 1; i <= n; i++) {
    scanf("%c", &s);
    valid[i] = (s == 'o');
  }
  int cur = -c;
  for (int i = 1; i <= k; i++) {
    for (int j = cur + c + 1; j <= n; j++)
      if (valid[j]) {
        l_minn[i] = j;
        cur = j;
        break;
      }
  }
  reverse(valid + 1, valid + n + 1);
  cur = -c;
  for (int i = 1; i <= k; i++) {
    for (int j = cur + c + 1; j <= n; j++)
      if (valid[j]) {
        r_minn[i] = n + 1 - j;
        cur = j;
        break;
      }
  }
  reverse(r_minn + 1, r_minn + k + 1);
  for (int i = 1; i <= k; i++)
    if (l_minn[i] == r_minn[i] && l_minn[i])
      printf("%d\\n", l_minn[i]);
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int maxn = 1e5 + 5;
bool valid[maxn];
int l_minn[maxn], r_minn[maxn];
int main() {
  int n, k, c;
  scanf("%d%d%d", &n, &k, &c);
  char s;
  scanf("%c", &s);
  for (int i = 1; i <= n; i++) {
    scanf("%c", &s);
    valid[i] = (s == 'o');
  }
  int cur = -c;
  for (int i = 1; i <= k; i++) {
    for (int j = cur + c + 1; j <= n; j++)
      if (valid[j]) {
        l_minn[i] = j;
        cur = j;
        break;
      }
  }
  reverse(valid + 1, valid + n + 1);
  cur = -c;
  for (int i = 1; i <= k; i++) {
    for (int j = cur + c + 1; j <= n; j++)
      if (valid[j]) {
        r_minn[i] = n + 1 - j;
        cur = j;
        break;
      }
  }
  reverse(r_minn + 1, r_minn + k + 1);
  for (int i = 1; i <= k; i++)
    if (l_minn[i] == r_minn[i] && l_minn[i])
      printf("%d\\n", l_minn[i]);
  return 0;
}