Problem p02721 (C++)

Buggy submission (status: Runtime Error):
/*
_____________________$$o____________________o$$$$$o__
___________________o$o_$$o____oo$$$$$$$oo______o$$$$o
______________$o________o$$$$$o___oo$$$$$$$o______$$$
______________$$$ooo________o$$$$o______o$$$$$o_____o
____________oo_____oo_____oo___o$$$$$______$$$$$$____
_________ooooo___$$o_$___oooooo___o$$$$o__o__o$$$$___
_______ooo__ooo$$$$o_$$ooooooooooo__o$$$o__oo_oo$$$o_
______oo_o$$o_$$_o$o_o$o__oooooooooo__o$$$o_oo__o$$$o
____oooooo$$$$o___oo__$$o_ooo_oooooooo__o$$o_ooo_o$$$
___ooooooo__o___oooo__$$ooooo$_oooooooo__o$$__ooo_$$$
_$$o_ooooo___o$$$$$o__o$o__o_$o__oooooooo_o$$o_oo__$$
_$$$o_ooo_________o$$_$$o____$$o_ooooooooo_$$$o_oo_$$
__oo________o$$o____o_$$o____o$ooooooooooo_o$$o_oo_o$
___o$$$$$$$$$$$$$o___$$$o____$$o_oooooooooo_$$$o_o_o$
________o__oo$$$$$o__$$$o____$$o____oooooo__$$$o_o_o$
_________$$$$$$$$$o__$$_____$$$o___________$$$oooooo_
__________o$$$$$$$o_________$$___________o$o___oooooo
___________o$$$$o_______________ooooo__oo$__ooo__oooo
________________________________ooo_$$oo___oooo$o____
________________________________oooo_$$$$$o___oo$$$o_
________________________________ooooo_o$$$$$o_____$$$
________________________________oooooo_o$$$$$$ooo___o
________________________________ooooooo__o$$$$$o_____
*/
#include <bits/stdc++.h>
#define ll long long
#define ft first
#define sd second
#define HageBaIO_KPOCCbI                                                       \
  int LOL;                                                                     \
  scanf("%d", &LOL);                                                           \
  for (int i = 0; i < LOL; i++)
#define Terrorist                                                              \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
using namespace std;
// BY |3 |<
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
// Where I am?
const ll N = 1e5 + 5;
const ll NN = 1e3 + 3;
const ll MOD = (1e9 + 7);
const ll MOD1 = 998244353;
const double PI = 3.14159265;
const int INF32 = 2e9;
const ll INF64 = 2e18;
// Don`t believe!!!//
int n, k, c, dp[N], x, mn;
map<int, vector<int>> mp;
string s;
void KEK() {
  cin >> n >> k >> c >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'o') {
      if (i <= c)
        dp[i] = 1;
      else
        dp[i] = max(dp[i - 1], dp[i - c - 1] + 1);
      if (dp[i] == k + 1)
        return;
    } else
      dp[i] = dp[i - 1];
  }
  x = k;
  mn = n - 1;
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == 'o') {
      if (dp[i] > x)
        mp[dp[i]].push_back(i + 1);
      else if (dp[i] == x && i <= mn) {
        mp[dp[i]].push_back(i + 1);
        mn -= c + 1;
        x--;
      }
    }
    if (mn == i)
      mn--;
  }
  for (int i = 1; i <= k; i++)
    if (mp[i].size() == 1)
      cout << mp[i][0] << endl;
}
int main() {
  Terrorist
  // HageBaIO_KPOCCbI
  KEK();
}
// TAUMAC, 9| BbIWEJI 3A TObOU!!!


Fixed submission:
/*
_____________________$$o____________________o$$$$$o__
___________________o$o_$$o____oo$$$$$$$oo______o$$$$o
______________$o________o$$$$$o___oo$$$$$$$o______$$$
______________$$$ooo________o$$$$o______o$$$$$o_____o
____________oo_____oo_____oo___o$$$$$______$$$$$$____
_________ooooo___$$o_$___oooooo___o$$$$o__o__o$$$$___
_______ooo__ooo$$$$o_$$ooooooooooo__o$$$o__oo_oo$$$o_
______oo_o$$o_$$_o$o_o$o__oooooooooo__o$$$o_oo__o$$$o
____oooooo$$$$o___oo__$$o_ooo_oooooooo__o$$o_ooo_o$$$
___ooooooo__o___oooo__$$ooooo$_oooooooo__o$$__ooo_$$$
_$$o_ooooo___o$$$$$o__o$o__o_$o__oooooooo_o$$o_oo__$$
_$$$o_ooo_________o$$_$$o____$$o_ooooooooo_$$$o_oo_$$
__oo________o$$o____o_$$o____o$ooooooooooo_o$$o_oo_o$
___o$$$$$$$$$$$$$o___$$$o____$$o_oooooooooo_$$$o_o_o$
________o__oo$$$$$o__$$$o____$$o____oooooo__$$$o_o_o$
_________$$$$$$$$$o__$$_____$$$o___________$$$oooooo_
__________o$$$$$$$o_________$$___________o$o___oooooo
___________o$$$$o_______________ooooo__oo$__ooo__oooo
________________________________ooo_$$oo___oooo$o____
________________________________oooo_$$$$$o___oo$$$o_
________________________________ooooo_o$$$$$o_____$$$
________________________________oooooo_o$$$$$$ooo___o
________________________________ooooooo__o$$$$$o_____
*/
#include <bits/stdc++.h>
#define ll long long
#define ft first
#define sd second
#define HageBaIO_KPOCCbI                                                       \
  int LOL;                                                                     \
  scanf("%d", &LOL);                                                           \
  for (int i = 0; i < LOL; i++)
#define Terrorist                                                              \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
using namespace std;
// BY |3 |<
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
// Where I am?
const ll N = 2e5 + 5;
const ll NN = 1e3 + 3;
const ll MOD = (1e9 + 7);
const ll MOD1 = 998244353;
const double PI = 3.14159265;
const int INF32 = 2e9;
const ll INF64 = 2e18;
// Don`t believe!!!//
int n, k, c, dp[N], x, mn;
map<int, vector<int>> mp;
string s;
void KEK() {
  cin >> n >> k >> c >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'o') {
      if (i <= c)
        dp[i] = 1;
      else
        dp[i] = max(dp[i - 1], dp[i - c - 1] + 1);
      if (dp[i] == k + 1)
        return;
    } else
      dp[i] = dp[i - 1];
  }
  x = k;
  mn = n - 1;
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == 'o') {
      if (dp[i] > x)
        mp[dp[i]].push_back(i + 1);
      else if (dp[i] == x && i <= mn) {
        mp[dp[i]].push_back(i + 1);
        mn -= c + 1;
        x--;
      }
    }
    if (mn == i)
      mn--;
  }
  for (int i = 1; i <= k; i++)
    if (mp[i].size() == 1)
      cout << mp[i][0] << endl;
}
int main() {
  Terrorist
  // HageBaIO_KPOCCbI
  KEK();
}
// TAUMAC, 9| BbIWEJI 3A TObOU!!!