Problem p02614 (C++) — buggy submission, verdict: Runtime Error

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(int &a, int b) {
  if (a > b)
    a = b;
}
void chmax(int &a, int b) {
  if (a < b)
    a = b;
}

void llchmin(ll &a, ll b) {
  if (a > b)
    a = b;
}
void llchmax(ll &a, ll b) {
  if (a < b)
    a = b;
}

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> sheet(h);
  rep(i, 0, h) cin >> sheet[i];

  ll ans = 0;

  for (int tmp1 = 0; tmp1 < (1 << 6); tmp1++) {
    bitset<6> s1(tmp1);

    if (h < 6 && s1.test(h))
      break;

    for (int tmp2 = 0; tmp2 < (1 << 6); tmp2++) {
      bitset<6> s2(tmp2);

      if (w < 6 && s2.test(w))
        break;

      vector<string> sh = sheet;

      rep(i, 0, 6) {
        if (i >= h)
          continue;
        if (s1.test(i)) {
          rep(j, 0, w) sh[i][j] = 'r';
        }
      }
      rep(i, 0, 6) {
        if (i >= w)
          continue;
        if (s2.test(i)) {
          rep(j, 0, h) sh[j][i] = 'r';
        }
      }

      int cnt = 0;

      rep(i, 0, h) {
        rep(j, 0, w) {
          if (sh[i][j] == '#')
            cnt++;
        }
      }

      if (cnt == k)
        ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Error: -6
/usr/include/c++/12/debug/vector:442:
In function:
    std::debug::vector<_Tp, _Allocator>::reference std::debug::vector<_Tp, 
    _Allocator>::operator[](size_type) [with _Tp = std::
    cxx11::basic_string<char>; _Allocator = std::allocator<std::
    cxx11::basic_string<char> >; reference = std::
    cxx11::basic_string<char>&; size_type = long unsigned int]

Error: attempt to subscript container with out-of-bounds index 2, but 
container only holds 2 elements.

Objects involved in the operation:
    sequence "this" @ 0x7ffc8c01f730 {
      type = std::debug::vector<std::cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >;
    }


Fixed submission:

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(int &a, int b) {
  if (a > b)
    a = b;
}
void chmax(int &a, int b) {
  if (a < b)
    a = b;
}

void llchmin(ll &a, ll b) {
  if (a > b)
    a = b;
}
void llchmax(ll &a, ll b) {
  if (a < b)
    a = b;
}

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> sheet(h);
  rep(i, 0, h) cin >> sheet[i];

  ll ans = 0;

  for (int tmp1 = 0; tmp1 < (1 << 6); tmp1++) {
    bitset<6> s1(tmp1);
    /*
    if(h < 6 && s1.test(h))
      break;
    */
    for (int tmp2 = 0; tmp2 < (1 << 6); tmp2++) {
      bitset<6> s2(tmp2);

      if (w < 6 && s2.test(w))
        break;

      vector<string> sh = sheet;

      rep(i, 0, 6) {
        if (s1.test(i)) {
          rep(j, 0, w) sh[i][j] = 'r';
        }
      }
      rep(i, 0, 6) {
        if (s2.test(i)) {
          rep(j, 0, h) sh[j][i] = 'r';
        }
      }
      int cnt = 0;

      rep(i, 0, h) {
        rep(j, 0, w) {
          if (sh[i][j] == '#')
            cnt++;
        }
      }

      if (cnt == k)
        ans++;
    }
  }

  cout << ans << endl;

  return 0;
}