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

#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl '\\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
// const int mod=1e9+7;
const int mod = 998244353;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int maxn = 2e5 + 10;
const ll inf = 0x3f3f3f3f;
const int dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

int l[maxn], r[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  int cnt = k - 1, mx = n;
  for (int i = s.length() - 1; i >= 0; i--)
    if (s[i] == 'o' && i < mx && cnt >= 0)
      r[cnt] = i, mx = i - c, cnt--;
  cnt = 0, mx = -1;
  for (int i = 0; i < s.length(); i++)
    if (s[i] == 'o' && i > mx)
      l[cnt] = i, mx = i + c, cnt++;
  for (int i = 0; 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 fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl '\\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
// const int mod=1e9+7;
const int mod = 998244353;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int maxn = 2e5 + 10;
const ll inf = 0x3f3f3f3f;
const int dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

int l[maxn], r[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  int cnt = k - 1, mx = n;
  for (int i = s.length() - 1; i >= 0; i--)
    if (s[i] == 'o' && i < mx)
      r[cnt] = i, mx = i - c, cnt--;
  cnt = 0, mx = -1;
  for (int i = 0; i < s.length(); i++)
    if (s[i] == 'o' && i > mx)
      l[cnt] = i, mx = i + c, cnt++;
  for (int i = 0; i < k; i++)
    if (l[i] == r[i])
      cout << l[i] + 1 << endl;
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY = 2147483647;

int main() {
  int n, k, c;
  string s;
  int A[200005] = {}, B[200005] = {};
  cin >> n >> k >> c >> s;
  int i = 0, cnt = 1;
  while (cnt <= k && i < n) {
    if (s[i] - 'o' == 0) {
      A[i] = cnt;
      cnt++;
      i += c;
    }
    i++;
  }
  i = n - 1;
  int cnt2 = k;
  while (i >= 0 && cnt2 > 0) {
    if (s[i] - 'o' == 0) {
      B[i] = cnt2;
      cnt2--;
      i -= c;
    }
    i--;
  }
  REP(i, n) {
    if (A[i] != 0 && A[i] == B[i])
      cout << i + 1 << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY = 2147483647;

int n, c;
string s;
vi v1;
vi v2;
bool f = true;

void printVector(vector<int> &vec) {
  cout << "size = " << vec.size() << endl;
  for (int i = 0; i < vec.size(); ++i) {
    cout << vec[i] << ", ";
  }
  cout << endl << endl;
}

void sekishugou(vi vec1, vi vec2) {
  sort(vec1.begin(), vec1.end());
  sort(vec2.begin(), vec2.end());

  vector<int> intersection(vec1.size() + vec2.size());

  vector<int>::iterator it = set_intersection(
      vec1.begin(), vec1.end(), vec2.begin(), vec2.end(), intersection.begin());
  v1.resize(it - intersection.begin());
  intersection.resize(it - intersection.begin());
  std::copy(intersection.begin(), intersection.end(), v1.begin());

  return;
}

void solve(int p, int k, int size) {
  if (p < n - (c + 1) * (k - 1) && k > 0) {
    FOR(i, p, n - (c + 1) * (k - 1)) {
      v2.resize(size);
      if (s[i] - 'o' == 0) {
        v2.push_back(i + 1);
        solve(i + 1 + c, k - 1, size + 1);
      }
    }
  } else if (k == 0) {
    if (f == true) {
      REP(i, v2.size()) v1.push_back(v2[i]);
      f = false;
    } else
      sekishugou(v1, v2);
  } else
    return;
}

int main() {
  int k;
  cin >> n >> k >> c >> s;
  solve(0, k, 0);
  REP(i, v1.size()) { cout << v1[i] << endl; }
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T> inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',')
    cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                                                               \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

const int N = 1e6 + 7;

int first[N];
int last[N];

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

  int day = 0;
  for (int i = 1; i <= k; i++) {
    while (calendar[day] == 'x') {
      day++;
    }
    first[i] = day;
    day += (c + 1);
  }

  day = sz(calendar) - 1;
  for (int i = k; i >= 1; i--) {
    while (calendar[day] == 'x') {
      day--;
    }
    last[i] = day;
    day -= (c + 1);
  }

  for (int i = 1; i <= k; i++) {
    if (first[i] == last[i]) {
      cout << first[i] + 1 << " ";
    }
  }
  cout << '\\n';

  return 0;
}

Error: WA

Fixed submission:

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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T> inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',')
    cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                                                               \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

const int N = 1e6 + 7;

int first[N];
int last[N];

int main() {
  _upgrade;
  int n, k;
  cin >> n >> k;
  string calendar;
  cin >> calendar;

  int day = 0;
  for (int i = 1; i <= n; i++) {
    while (calendar[day] == 'x') {
      day++;
    }
    first[i] = day;
    day += (k + 1);
  }

  day = sz(calendar) - 1;
  for (int i = n; i >= 1; i--) {
    while (calendar[day] == 'x') {
      day--;
    }
    last[i] = day;
    day -= (k + 1);
  }

  for (int i = 1; i <= n; i++) {
    if (first[i] == last[i]) {
      cout << first[i] + 1 << " ";
    }
  }
  cout << '\\n';

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

#include <bits/stdc++.h>
#define ll long long int
#define MOD1 1000000007
#define MOD2 998244353
#define BOOST                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)

using namespace std;

ll n, k, c;
string s;
vector<vector<ll>> ans;
vector<ll> row;
ll a[200010], b[200010];
void backtrack(ll pos, ll daysLeft) {
  if (daysLeft == 0) {
    ans.push_back(row);
    return;
  }
  if (pos >= n)
    return;
  if (s[pos] == 'x')
    backtrack(pos + 1, daysLeft);
  else {
    row.push_back(pos);
    backtrack(pos + c + 1, daysLeft - 1);
    row.pop_back();
    backtrack(pos + 1, daysLeft);
  }
}

void solve() {
  cin >> n >> k >> c >> s;
  ll cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'o') {
      a[cnt++] = i;
      i += c;
    }
  }
  cnt = 0;

  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == 'o') {
      b[cnt++] = i;
      i -= c;
    }
  }
  // for(int i = 0; i < k; i++)
  //     cout << a[i] << " " << b[i] << "\\n";
  for (int i = 0; i < k; ++i) {
    if (a[i] == b[k - i - 1])
      cout << a[i] + 1 << "\\n";
  }
  /*
  Find the earliest and latest day of
  the i-th working day. If for some i they are the same,
  this is a day bound to work.
  */
}

int main() {
  // #ifndef ONLINE_JUDGE
  //    freopen("input.txt", "r", stdin);
  //    freopen("output.txt", "w", stdout);
  // #endif

  ll t = 1;
  // cin >> t;
  while (t--)
    solve();

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int
#define MOD1 1000000007
#define MOD2 998244353
#define BOOST                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)

using namespace std;

ll n, k, c;
string s;
vector<vector<ll>> ans;
vector<ll> row;
void backtrack(ll pos, ll daysLeft) {
  if (daysLeft == 0) {
    ans.push_back(row);
    return;
  }
  if (pos >= n)
    return;
  if (s[pos] == 'x')
    backtrack(pos + 1, daysLeft);
  else {
    row.push_back(pos);
    backtrack(pos + c + 1, daysLeft - 1);
    row.pop_back();
    backtrack(pos + 1, daysLeft);
  }
}

void solve() {
  cin >> n >> k >> c >> s;
  backtrack(0, k);
  map<ll, ll> days;
  for (auto i : ans) {
    for (auto j : i) {
      if (days.find(j) == days.end())
        days.insert({j, 1});
      else
        days[j]++;
      // cout << j + 1 << ", ";
    }
    // cout << "\\n";
  }
  for (auto i : days) {
    if (i.second == ans.size())
      cout << i.first + 1 << "\\n";
    // cout << i.first << " = " << i.second << "\\n";
  }
  // cout << days.size();
}

int main() {
  // #ifndef ONLINE_JUDGE
  //    freopen("input.txt", "r", stdin);
  //    freopen("output.txt", "w", stdout);
  // #endif

  ll t = 1;
  // cin >> t;
  while (t--)
    solve();

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

#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define ALL(a) (a.begin()), (a.end())

int64_t N;
int64_t K;
int64_t C;
vector<int> L;
vector<int> R;
string S;
int main() {

  cin >> N >> K >> C >> S;

  for (int i = 0; i < N; i++) {
    if (S[i] == 'o') {
      L.push_back(i);
      i = i + C;
    }
  }

  for (int i = N - 1; i >= 0; i--) {
    if (S[i] == 'o') {
      R.push_back(i);
      i = i - C;
    }
  }
  reverse((R.begin()), (R.end()));

  int64_t x = 0;
  int64_t j = 0;

  for (int i = 0; i < N; i++) {
    if (S[i] == 'o') {
      x = lower_bound((L.begin()), (L.end()), i) - L.begin();
      j = lower_bound(ALL(R), i + 1) - R.begin();
      j = R.size() - j;
      if (x + j < K)
        cout << i + 1 << endl;
    }
  }

  return 0;
}


Error: 0

Fixed submission:

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

int64_t N;
int64_t K;
int64_t C;
int64_t L[200000];
int64_t R[200000];
string S;
int main() {

  cin >> N;
  cin >> K;
  cin >> C;
  cin >> S;

  int64_t x = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'o') {
      L[x] = i;
      x++;
      i = i + C;
    }
  }
  x = K - 1;
  for (int i = N - 1; i >= 0; i--) {
    if (S[i] == 'o') {
      R[x] = i;
      x--;
      i = i - C;
    }
  }

  for (int i = 0; i < K; i++) {
    if (L[i] == R[i]) {
      std::cout << L[i] + 1 << "\\n";
    }
  }

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

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

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, c;
  vector<int> a, b;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  for (int i = 0; i < n; i++)
    if (s[i] == 'o') {
      a.push_back(i);
      i += c;
    };
  for (int i = n - 1; i > 0; i--)
    if (s[i] == 'o') {
      b.push_back(i);
      i -= c;
    };
  for (int i = 0; i < k; i++)
    if (a[i] == b[k - i - 1]) {
      cout << a[i] + 1 << '\\n';
    };
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

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

// template
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(v) (v).begin(), (v).end()
typedef long long int ll;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;
const double eps = 1e-12;
void tostr(ll x, string &res) {
  while (x)
    res += ('0' + (x % 10)), x /= 10;
  reverse(ALL(res));
  return;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
// end

bool f[201000] = {};

int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  int sum = 0;
  rep(i, 0, n) if (s[n - 1 - i] == 'o') {
    sum++;
    f[n - 1 - i] = 1;
    i += c;
  }
  if (sum > k)
    return 0;
  rep(i, 0, s.size()) if (s[i] == 'o') {
    if (f[i])
      cout << i + 1 << endl;
    i += c;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

// template
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(v) (v).begin(), (v).end()
typedef long long int ll;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;
const double eps = 1e-12;
void tostr(ll x, string &res) {
  while (x)
    res += ('0' + (x % 10)), x /= 10;
  reverse(ALL(res));
  return;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
// end

int nxt[201000];
int ig[201000];

int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  int mi = inf, mi2 = inf;
  rrep(i, n, 0) {
    ig[i] = mi2;
    if (s[i - 1] == 'o')
      mi2 = i;
  }
  rrep(i, n, 0) {
    if (s[i - 1] == 'o')
      nxt[i] = mi;
    else
      nxt[i] = inf;
    if (i + c != 0 and i + c <= n and s[i + c - 1] == 'o')
      mi = i + c;
  }
  nxt[0] = 1;
  ig[0] = 1;
  // rep(i,0,n+1)cerr<<ig[i]<<endl; puts("");
  int cc = 0, ccnt = 0;
  while (cc != inf) {
    cc = nxt[cc];
    ccnt++;
  }
  if (ccnt < k)
    return 0;
  rep(i, 1, n + 1) {
    int cur = 0, cnt = 0;
    while (cur != inf) {
      cur = nxt[cur];
      if (cur == i)
        cur = ig[i];
      if (cur == inf)
        break;
      cnt++;
    }
    if (cnt < k) {
      cout << i << endl;
    }
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
const int N = 220000;
char s[N];
int l[N], r[N];
int n, k, c;
int main() {
  scanf("%d%d%d%s", &n, &k, &c, s + 1);

  int i = 1, kk = 1;
  while (kk <= k) {
    if (s[i] == 'o')
      l[kk++] = i, i += c;
    ++i;
  }

  i = n, kk = k;
  while (kk) {
    if (s[i] == 'o')
      r[kk--] = i, i -= c;
    --i;
  }

  for (i = 1; i <= k; ++i)
    if (l[i] == r[i])
      printf("%d\\n", l[i]);

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int N = 110000;
char s[N];
int l[N], r[N];
int n, k, c;
int main() {
  scanf("%d%d%d%s", &n, &k, &c, s + 1);

  int i = 1, kk = 1;
  while (kk <= k) {
    if (s[i] == 'o')
      l[kk++] = i, i += c;
    ++i;
  }

  i = n, kk = k;
  while (kk) {
    if (s[i] == 'o')
      r[kk--] = i, i -= c;
    --i;
  }

  for (i = 1; i <= k; ++i)
    if (l[i] == r[i])
      printf("%d\\n", l[i]);

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

#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;

  vector<int> l(0), r(0);
  rep(i, n) {
    if (s[i] == 'o') {
      if (l.size() < k) {
        l.push_back(i);
        i += c;
      } else {
        break;
      }
    }
  }

  rep(i, n) {
    if (s[n - i - 1] == 'o') {
      if (r.size() < k) {
        r.push_back(n - i - 1);
        i += c;
      } else {
        break;
      }
    }
  }

  rep(x, k) {
    if (l[x] == r[r.size() - x - 1]) {
      cout << (l[x] + 1) << endl;
    }
    // cout << l[x] << " " << r[x] << endl;
  }
}


Error: TLE

Fixed submission:

#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;

  vector<int> l(0), r(0);
  rep(i, n) {
    if (s[i] == 'o') {
      if (l.size() < k) {
        l.push_back(i);
        i += c;
      } else {
        break;
      }
    }
  }

  rep(i, n) {
    if (s[n - i - 1] == 'o') {
      if (r.size() < k) {
        r.insert(r.begin(), n - i - 1);
        i += c;
      } else {
        break;
      }
    }
  }

  rep(x, l.size()) {
    if (l[x] == r[x]) {
      cout << (l[x] + 1) << endl;
    }
  }
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>
#include <stack>
using namespace std;
typedef long long ll;
ll n, k, c, lst;
bool flag;
string s;
ll cnt;
bool vis[200010];
stack<int> stk;
int main() {
  cin >> n >> k >> c;
  cin >> s;
  lst = -1;
  for (int i = 0; i < (int)(s.length()); i++) {
    if (s[i] == 'x' || lst >= i)
      continue;
    if (cnt >= k) {
      flag = 1;
      break;
    }
    lst = i + c;
    vis[i] = 1;
    cnt++;
  }
  if (flag) {
    return 0;
  }
  lst = s.length();
  for (int i = (int)s.length() - 1; i >= 0; i--) {
    if (s[i] == 'x' || lst <= i)
      continue;
    lst = i - c;
    if (vis[i]) {
      stk.push(i);
    }
  }
  while (!stk.empty()) {
    cout << stk.top() + 1 << endl;
    ;
    stk.pop();
  }
  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
#include <iostream>
#include <stack>
using namespace std;
typedef long long ll;
ll n, k, c, lst;
bool flag;
string s;
ll cnt;
bool vis[100010];
stack<int> stk;
int main() {
  cin >> n >> k >> c;
  cin >> s;
  lst = -1;
  for (int i = 0; i < (int)(s.length()); i++) {
    if (s[i] == 'x' || lst >= i)
      continue;
    if (cnt >= k) {
      flag = 1;
      break;
    }
    lst = i + c;
    vis[i] = 1;
    cnt++;
  }
  if (flag) {
    return 0;
  }
  lst = s.length();
  for (int i = (int)s.length() - 1; i >= 0; i--) {
    if (s[i] == 'x' || lst <= i)
      continue;
    lst = i - c;
    if (vis[i]) {
      stk.push(i);
    }
  }
  while (!stk.empty()) {
    cout << stk.top() + 1 << endl;
    ;
    stk.pop();
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for (int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

int main() {
  int N, K, C;
  string S;
  cin >> N >> K >> C >> S;
  vector<int> L(K);
  vector<int> R(K);
  int ind = 0;
  int wsum = 0;
  while (ind < N) {
    if (wsum >= K) {
      break;
    }
    if (S[ind] == 'x') {
      ind++;
    } else {
      L[wsum] = ind;
      wsum++;
      ind += 1 + C;
    }
  }
  ind = N - 1;
  wsum = 0;
  while (ind >= 0) {
    if (wsum >= K) {
      break;
    }
    if (S[ind] == 'x') {
      ind--;
    } else {
      R[K - 1 - wsum] = ind;
      wsum++;
      ind -= 1 + C;
    }
  }

  rep(i, 0, K) {
    // cout << "L:" << L[i] << ",R:" << R[i] << endl;
    if (L[i] == R[i]) {
      cout << L[i] + 1 << endl;
    }
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for (int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

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

  int ind = 0;
  int wsum = 0;
  while (ind < N) {
    if (S[ind] == 'x') {
      ind++;
    } else {
      kouho.insert(ind);
      wsum++;
      ind += 1 + C;
    }
  }
  for (auto k : kouho) {
    // cout << k << endl;
    string ts = S;
    ts[k] = 'x';
    // cout << ts << endl;
    int t = 0;
    int tsum = 0;
    while (t < N) {
      if (ts[t] == 'x') {
        t++;
      } else {
        tsum++;
        t += 1 + C;
      }
    }
    if (tsum < K) {
      cout << k + 1 << endl;
    }
  }
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
const int MAX = 1e5 + 10;
const double exps = 1e-8;
#define swap(a, b)                                                             \\
  {                                                                            \\
    register int tmp = a;                                                      \\
    a = b;                                                                     \\
    b = tmp;                                                                   \\
  }

inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a > b ? b : a; }
int n, k, c;
vector<int> L, R;
string s;
int main() {
  cin >> n >> k >> c >> s;
  for (int i = 1; i <= s.size();) {
    if (s[i - 1] == 'o') {
      L.push_back(i);
      i += c;
    }
    i++;
    if (L.size() == k)
      break;
  }
  for (int i = s.size(); i >= 1;) {
    if (s[i - 1] == 'o') {
      R.push_back(i);
      i -= c;
    }
    --i;
    if (R.size() == k)
      break;
  }
  for (int i = 0; i < k; ++i) {
    if (L[i] == R[k - 1 - i])
      printf("%d\\n", L[i]);
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10;
const int MAX = 1e5 + 10;
const double exps = 1e-8;
#define swap(a, b)                                                             \\
  { register int tmp = a, a = b, b = tmp; }

inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a > b ? b : a; }
int n, k, c;
string s;
bool vis[N];
int ans[N], pp;
void dfs(int day, int cnt) {
  if (cnt == k) {
    pp++;
    for (int i = 1; i <= n; ++i) {
      ans[i] += vis[i];
    }
    return;
  }
  for (int i = day + 1; i < n; ++i) {
    if (s[i] != 'x' && !vis[i]) {
      vis[i + 1] = 1;
      dfs(i + c, cnt + 1);
      vis[i + 1] = 0;
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &k, &c);
  cin >> s;
  dfs(-1, 0);
  for (int i = 1; i <= n; ++i) {
    if (ans[i] == pp) {
      printf("%d\\n", i);
    }
  }
}