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

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

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  // cin >> t;
  while (t--) {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> a(h);
    int b = 0;
    for (int i = 0; i < h; i++) {
      cin >> a[i];
      for (char c : a[i]) {
        if (c == '#')
          b++;
      }
    }
    if (b < k) {
      cout << 0;
      return 0;
    }
    int ans = 0;
    for (int r = 0; r <= (1 << h) - 1; r++) {
      for (int c = 0; c <= (1 << w) - 1; c++) {
        int cnt = 0;
        vector<vector<int>> vis(h, vector<int>(w));
        for (int i = 0; i < h; i++) {
          if (r & (1 << i)) {
            for (int j = 0; j < w; j++) {
              if (a[i][j] == '#')
                cnt++;
              vis[i][j] = 1;
            }
          }
        }
        for (int i = 0; i < w; i++) {
          if (c & (1 << i)) {
            for (int j = 0; j < h; j++) {
              if (a[j][i] == '#' && !vis[j][i])
                cnt++;
            }
          }
        }
        if (b - cnt == k) {
          // cout << r << " " << c << endl;
          ans++;
        }
      }
    }
    cout << ans;
  }
  return 0;
}

Error: -11

Fixed submission:

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

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  // cin >> t;
  while (t--) {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> a(h);
    int b = 0;
    for (int i = 0; i < h; i++) {
      cin >> a[i];
      for (char c : a[i]) {
        if (c == '#')
          b++;
      }
    }
    if (b < k) {
      cout << 0;
      return 0;
    }
    int ans = 0;
    for (int r = 0; r <= (1 << 6) - 1; r++) {
      for (int c = 0; c <= (1 << 6) - 1; c++) {
        int cnt = 0;
        for (int i = 0; i < 6; i++) {
          if (r & (1 << i)) {
            for (int j = 0; j < w; j++) {
              if (a[i][j] == '#')
                cnt++;
            }
          }
        }
        for (int i = 0; i < 6; i++) {
          if (c & (1 << i)) {
            for (int j = 0; j < h; j++) {
              if (a[j][i] == '#')
                cnt++;
            }
          }
        }
        if (b - cnt == k)
          ans++;
      }
    }
    cout << ans;
  }
  return 0;
}
Problem p02614 (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 argc, const char *argv[]) {

  cin.tie(0);
  ios::sync_with_stdio(false);

  int h, w, k, cnt = 0;
  cin >> h >> w >> k;
  char c[h][w], d[h][w];
  rep(i, h) {
    rep(j, w) { cin >> c[i][j]; }
  }

  for (int bit = 0; bit < (1 << h + w); ++bit) {
    rep(a, h) {
      rep(b, w) { d[a][b] = c[a][b]; }
    }
    for (int i = 0; i < (h + w); ++i) {
      if (bit & (1 << i)) {
        if (i < h) {
          rep(x, w) { d[i][x] = '1'; }
        } else {
          rep(y, h) { d[y][i - h] = '1'; }
        }
      }
    }
    int b_cnt = 0;
    rep(a, h) {
      rep(b, w) {
        if (d[a][b] == '#')
          b_cnt++;
      }
    }
    if (b_cnt == k) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


Error: WA

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 argc, const char *argv[]) {

  cin.tie(0);
  ios::sync_with_stdio(false);

  int h, w, k, cnt = 0;
  cin >> h >> w >> k;
  int c[h][w], d[h][w];
  rep(i, w) {
    rep(j, h) { cin >> c[i][j]; }
  }

  for (int bit = 0; bit < h + w; ++bit) {
    rep(a, w) {
      rep(b, h) { d[a][b] = c[a][b]; }
    }
    for (int i = 0; i < h + w; ++i) {
      if (bit & (1 << i)) {
        if (i < h) {
          rep(x, w) { d[i][x] = '.'; }
        } else {
          rep(y, h) { d[y][i - h - 1] = '.'; }
        }
      }
    }
    int b_cnt = 0;
    rep(a, w) {
      rep(b, h) {
        if (d[a][b] == '#')
          b_cnt++;
      }
    }
    if (b_cnt == k)
      cnt++;
  }

  cout << cnt << endl;

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int h, w, k;

int cnt(vector<string> s, bool retu, int n) {
  int ret = 0;
  if (retu) {
    rep(i, h) {
      if (s[i][n] == '#')
        ret++;
    }
  } else {
    rep(i, w) {
      if (s[n][i] == '#')
        ret++;
    }
  }
  return ret;
}

int main() {
  cin >> h >> w >> k;
  Int ans = 0;
  vector<string> c(h);
  rep(i, h) cin >> c[i];
  for (int p = 0; p < (1 << h); p++) {
    for (int q = 0; q < (1 << w); q++) {
      int black = 0;
      vector<string> cop = c;
      rep(i, h) {
        rep(j, w) {
          if (q & (1 << j) || p & (1 << i))
            continue;
          if (c[i][j] == '#')
            black++;
        }
      }
      if (black == k)
        ans++;
    }
  }
  cout << ans << endl;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int h, w, k;

int cnt(vector<string> s, bool retu, int n) {
  int ret = 0;
  if (retu) {
    rep(i, h) {
      if (s[i][n] == '#')
        ret++;
    }
  } else {
    rep(i, w) {
      if (s[n][i] == '#')
        ret++;
    }
  }
  return ret;
}

int main() {
  cin >> h >> w >> k;
  Int ans = 0;
  vector<string> c(h);
  rep(i, h) cin >> c[i];
  for (int p = 0; p < (1 << h); p++) {
    for (int q = 0; q < (1 << w); q++) {
      int black = 0;
      rep(j, w) {
        if (q & (1 << j))
          continue;
        black += cnt(c, false, j);
      }
      rep(i, h) {
        if (p & (1 << i))
          continue;
        black += cnt(c, true, i);
      }
      if (black == k)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

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

#define INF (i64)1e18
#define MOD (i64)(1e9 + 7)
#define REP(i, n) for (i64 i = 0; i < n; i++)
#define RANGE(i, a, b) for (i64 i = a; i < b; i++)
#define EACH(v, e, p) for_each(v.begin(), v.end(), [](auto &e) p)

int main() {
  int h, w, k;
  cin >> h >> w >> k;

  vector<vector<bool>> c(h, vector<bool>(w));
  REP(i, h) {
    string s;
    cin >> s;
    REP(j, w) { c[i][j] = s[j] == '#'; }
  }

  int ans = 0;
  for (int wbit = 0; wbit < (1 << w); ++wbit) {
    for (int hbit = 0; hbit < (1 << h); ++hbit) {
      int count = 0;
      for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
          if ((wbit & (1 << i)) && (hbit & (1 << j))) {
            if (c[j][i])
              count++;
          }
        }
      }
      if (count == k)
        ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Error: -11

Fixed submission:

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

#define INF (i64)1e18
#define MOD (i64)(1e9 + 7)
#define REP(i, n) for (i64 i = 0; i < n; i++)
#define RANGE(i, a, b) for (i64 i = a; i < b; i++)
#define EACH(v, e, p) for_each(v.begin(), v.end(), [](auto &e) p)

int main() {
  int h, w, k;
  cin >> h >> w >> k;

  vector<vector<bool>> c(h, vector<bool>(w));
  REP(i, h) {
    string s;
    cin >> s;
    REP(j, w) { c[i][j] = s[j] == '#'; }
  }

  int ans = 0;
  for (int wbit = 0; wbit < (1 << w); ++wbit) {
    for (int hbit = 0; hbit < (1 << h); ++hbit) {
      int count = 0;
      for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
          if ((wbit & (1 << i)) && (hbit & (1 << j))) {
            if (c[i][j])
              count++;
          }
        }
      }
      if (count == k)
        ans++;
    }
  }
  cout << ans << endl;

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;

int main(void) {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);

  for (int i = 0; i < h; i++) {
    cin >> c[i];
  }

  int ans = 0;
  for (int bith = 0; bith < (1 << h); bith++) {
    for (int bitw = 0; bitw < (1 << w); bitw++) {

      int cntb = 0;
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          if (c[i][j] == '#') {
            if (((bith >> i) & 1) == 0 && ((bitw >> j) & 1) == 0) {
              cntb++;
            }
          }
        }
      }
      if (cntb == k)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;

int main(void) {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(w);

  for (int i = 0; i < h; i++) {
    cin >> c[i];
  }

  int ans = 0;
  for (int bith = 0; bith < (1 << h); bith++) {
    for (int bitw = 0; bitw < (1 << w); bitw++) {

      int cntb = 0;
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          if (c[i][j] == '#') {
            if (((bith >> i) & 1) == 0 && ((bitw >> j) & 1) == 0) {
              cntb++;
            }
          }
        }
      }
      if (cntb == k)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

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

bool is_bit_set(uint32_t x, uint8_t n) {
  bool ret;
  ret = (x >> n) & 1U;

  return ret;
}

int main() {
  uint32_t H;
  uint32_t W;
  uint32_t K;
  cin >> H >> W >> K;

  string S[6];
  for (size_t i = 0; i < H; i++) {
    cin >> S[i];
  }

  uint32_t ans;
  ans = 0;
  for (uint32_t h = 0; h < (uint32_t)(1 << H); h++)
    for (uint32_t w = 0; w < (uint32_t)(1 << W); w++) {
      uint32_t k;
      k = 0;
      for (uint32_t i = 0; i < H; i++)
        for (uint32_t j = 0; j < W; j++) {
          if (is_bit_set(h, i) && is_bit_set(w, j)) {
            if (S[i][j] == '#') {
              k = k + 1;
            }
          }
        }

      if (k == K) {
        ans = ans + 1;
      }
    }

  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

bool is_bit_set(uint32_t x, uint8_t n) {
  bool ret;
  ret = (x >> n) & 1U;

  return ret;
}

int main() {
  uint8_t H;
  uint8_t W;
  uint8_t K;
  cin >> H >> W >> K;

  string S[6];
  for (size_t i = 0; i < H; i++) {
    cin >> S[i];
  }

  uint8_t ans;
  ans = 0;
  for (size_t h = 0; h < (1 << H); h++) {
    for (size_t w = 0; w < (1 << W); w++) {
      uint8_t k;
      k = 0;
      for (uint8_t i = 0; i < H; i++) {
        for (uint8_t j = 0; j < W; j++) {
          if (is_bit_set(h, i) && is_bit_set(w, j)) {
            if (S[i][j] == '#') {
              k = k + 1;
            }
          }
        }
      }

      if (k == K) {
        ans = ans + 1;
      }
    }
  }

  cout << ans << endl;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

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

const double PI = acos(-1);

int H, W, K;

int count(int h, int w, vector<vector<int>> arr) {
  int sum = 0;
  rep(i, H) {
    rep(j, W) {
      if ((1 << i & h) != 0 && (1 << j & w) != 0)
        sum += arr[i][j];
    }
  }
  return sum;
}

int main() {
  cin >> H >> W >> K;
  vector<vector<int>> field;
  field.assign(H, vector<int>(W, 0));
  string in;
  rep(i, H) {
    cin >> in;
    rep(j, W) {
      if (in[j] == '#')
        field.at(i).at(j) = 1;
    }
  }
  int result = 0;
  rep(i, 1 << H) {
    rep(j, 1 << W) {
      if (count(i, j, field) == K)
        result++;
    }
  }
  cout << result << "\\n";
}

Error: -11

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>;
using Graph = vector<vector<int>>;

const double PI = acos(-1);

int H, W, K;
int cnt;

void dfs(int h, int w, vector<vector<int>> field) {
  // cout << "実行" << endl;
  int tmp = 0;
  for (int i = 0; i < W; ++i) {
    field[h][i] = 0;
  }
  for (int i = 0; i < H; ++i) {
    field[i][w] = 0;
  }
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      // cout << "arr[" << i << "][" << j << "]:" << arr[i][j] << endl;
      tmp += field[i][j];
    }
  }
  // cout << "tmp:" << tmp << endl;
  if (tmp == K)
    ++cnt;
  if (h + 1 > H || w + 1 > W)
    return;
  dfs(h, w + 1, field);
  dfs(h + 1, w, field);
}

int main() {
  cin >> H >> W >> K;
  vector<vector<int>> field;
  field.assign(H, vector<int>(W, 0));
  // 入力 (2重ループを用いる)
  string in;
  for (int i = 0; i < H; ++i) {
    cin >> in;
    for (int j = 0; j < W; ++j) {
      if (in[j] == '#') {
        field.at(i).at(j) = 1;
      }
      cout << "field[" << i << "][" << j << "]:" << field[i][j] << endl;
    }
  }
  // 探索開始
  dfs(0, 0, field);
  cout << cnt << endl;
  return 0;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> vec(H);
  for (int i = 0; i < H; i++) {
    cin >> vec[i];
  }
  int ans = 0;
  for (int is = 0; is < (1 << H); is++) {
    for (int js = 0; js < (1 << W); js++) {
      int cnt = 0;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (is >> i & 1) {
            continue;
          }
          if (js >> j & 1) {
            continue;
          }
          if (vec[i][j] == '#') {
            cnt++;
          }
        }
      }
      if (cnt == K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> vec(W);
  for (int i = 0; i < H; i++) {
    cin >> vec[i];
  }
  int ans = 0;
  for (int is = 0; is < (1 << H); is++) {
    for (int js = 0; js < (1 << W); js++) {
      int cnt = 0;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (is >> i & 1) {
            continue;
          }
          if (js >> j & 1) {
            continue;
          }
          if (vec[i][j] == '#') {
            cnt++;
          }
        }
      }
      if (cnt == K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  int H, W, K, cnt = 0;
  cin >> H >> W >> K;

  vector<vector<char>> c(H, vector<char>(W));

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++)
      cin >> c.at(i).at(j);
  }

  int h_all = 1 << H;
  int w_all = 1 << W;

  for (int h_mask = 0; h_mask < h_all; h_mask++) {
    for (int w_mask = 0; w_mask < w_all; w_mask++) {
      int bcnt = 0;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if ((h_mask >> i) & 1 && (w_mask >> j) & 1 && c.at(i).at(j) == '#') {
            bcnt++;
          }
        }
      }
      if (bcnt == K)
        cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)


Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  int H, W, K, bsum = 0;
  cin >> H >> W >> K;

  vector<vector<char>> c(H, vector<char>(W));

  for (int i = 0; i < H; i++) {
    for (int j = 0; i < W; j++)
      cin >> c.at(i).at(j);
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (c.at(i).at(j) == '#')
        bsum++;
    }
  }

  int h_all = 1 << H;
  int w_all = 1 << W;

  for (int h_mask = 0; h_mask < h_all; h_mask++) {
    for (int i = 0; i < H; i++) {
      if ((h_mask >> i) & 1) {
        for (int j = 0; j < W; j++) {
          if (c.at(i).at(j) == 'B')
            bsum--;
        }
      }
    }

    for (int w_mask = 0; w_mask < w_all; w_mask++) {
      for (int j = 0; j < W; j++) {
        if ((w_mask >> j) & 1) {
          for (int i = 0; i < H; i++) {
            if (c.at(i).at(j) == 'B')
              bsum--;
          }
        }
      }
    }
  }
  return 0;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<bool>> c(h, vector<bool>(w));
  rep(i, h) rep(j, w) {
    char ch;
    cin >> ch;
    if (ch == '#')
      c[i][j] = 1;
    else
      c[i][j] = 0;
  }
  int cnt = 0;
  for (int i = 0; i < (1 << h); i++) {
    bitset<6> s(i);
    for (int j = 0; j < (1 << w); j++) {
      bitset<6> t(j);
      int tmp = 0;
      rep(l, h) {
        rep(m, w) {
          if (c[l][m] && !s.test(l) && !t.test(m))
            tmp++;
        }
      }
      if (tmp == k)
        cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<bool>> c(h, vector<bool>(w));
  rep(i, h) rep(j, w) {
    char ch;
    cin >> ch;
    if (ch == '#')
      c[i][j] = 1;
    else
      c[i][j] = 0;
  }
  int cnt = 0;
  for (int i = 0; i < (1 << h); i++) {
    bitset<3> s(i);
    for (int j = 0; j < (1 << w); j++) {
      bitset<3> t(j);
      int tmp = 0;
      rep(l, h) {
        rep(m, w) {
          if (c[l][m] && !s.test(l) && !t.test(m))
            tmp++;
        }
      }
      if (tmp == k)
        cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> c(H);
  for (int i = 0; i < H; ++i)
    cin >> c[i];
  int res = 0;
  for (int i = 0; i < (1 << H); ++i) {
    for (int j = 0; j < (1 << W); ++j) {
      int black = 0;
      for (int x = 0; x < H; ++x) {
        for (int y = 0; y < W; ++y) {
          if ((i >> x) & 1)
            continue; // bitにi番目のフラグが立っているかどうか((bit>>i)&1)
          if ((j >> y) & 1)
            continue;
          if (c[x][y] == '#')
            black++;
        }
      }
      if (black == K)
        res++;
    }
  }
  cout << res << endl;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> c(H);
  vector<int> tate(H, 0);
  vector<int> yoko(W, 0);
  ll black = 0;
  for (int i = 0; i < H; ++i) {
    cin >> c[i];
    for (int j = 0; j < W; ++j) {
      black++;
      tate[i]++;
      yoko[j]++;
    }
  }
  ll res = 0;
  vector<vector<int>> SX((1 << H));
  vector<vector<int>> SY((1 << W));
  for (int bitx = 0; bitx < (1 << H); ++bitx) {
    for (int i = 0; i < H; ++i) {
      if (bitx & (1 << i)) {
        SX[bitx].push_back(i);
      }
    }
  }
  for (int bity = 0; bity < (1 << W); ++bity) {
    for (int i = 0; i < W; ++i) {
      if (bity & (1 << i)) {
        SY[bity].push_back(i);
      }
    }
  }
  for (int i = 0; i < SX.size(); ++i) {
    int tmp = black;
    for (auto &&X : SX[i]) {
      tmp = black - tate[X];
      for (int j = 0; j < SY.size(); ++j) {
        for (auto &&Y : SY[i]) {
          tmp = black - yoko[Y];
          if (c[X][Y] == '#')
            tmp++;
          if (tmp == K)
            res++;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

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

using ll = long long;

int H, W, K;
vector<string> v;
vector<int> mass;
vector<int> massb;
int ans;
int check() {
  int cnt = 00;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (mass[i] == 0 && massb[j] == 0 && v[i][j] == '#') {
        cnt++;
      }
    }
  }
  if (cnt == K)
    ans++;
  return 0;
}

int zrk() {
  for (int i = 0; i < (1 << H); i++) {
    for (int j = 0; j < H; j++) {
      mass[j] = i & (1 << j);
    }
    for (int k = 0; k < (1 << W); k++) {
      for (int l = 0; l < W; l++) {
        massb[l] = k & (1 << l);
      }
      check();
    }
  }
  return 0;
}

int main() {
  cin >> H >> W >> K;
  mass = vector<int>(H);
  massb = vector<int>(W);
  for (int i = 0; i < H; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  zrk();
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

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

using ll = long long;

int H, W, K;
vector<string> v;
int mass[10];
int massb[10];
int ans;
int check() {
  int cnt = 00;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (mass[i] == 0 && massb[j] == 0 && v[i][j] == '#') {
        cnt++;
      }
    }
  }
  if (cnt == K)
    ans++;
  return 0;
}
int zrk1(int i) {
  if (W == i) {
    check();
    return 0;
  }
  massb[i] = 1;
  zrk1(i + 1);
  massb[i] = 0;
  zrk1(i + 1);
}

int zrk(int i) {
  if (H == i) {
    zrk1(0);
    return 0;
  }
  mass[i] = 1;
  zrk(i + 1);
  mass[i] = 0;
  zrk(i + 1);
}

int main() {
  cin >> H >> W >> K;

  for (int i = 0; i < H; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  zrk(0);
  cout << ans << endl;
  return 0;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>

using namespace std;

int main() {
  int H, W, K;
  scanf("%d%d%d", &H, &W, &K);
  string m[H];
  for (int i = 0; i < H; i++) {
    cin >> m[i];
  }
  int count = 0;
  for (int b = 0; b < 1 << (H + W); b++) {
    int black = 0;
    for (int i = 0; i < H * W; i++) {
      if (b >> (i / W) & 1 && b >> (H + i % W) & 1) {
        if (m[i / W][i % W] == '#') {
          if (++black > K) {
            break;
          }
        }
      }
    }
    if (black == K) {
      count++;
    }
  }
  printf("%d\\n", count);
  return 0;
}


Error: -11

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  int H, W, K;
  scanf("%d%d%d", &H, &W, &K);
  string m[H];
  for (int i = 0; i < H; i++) {
    cin >> m[i];
  }
  int count = 0;
  for (int b = 0; b < 1 << (H + W); b++) {
    int black = 0;
    for (int i = 0; i < H * W; i++) {
      if (b >> (i / H) & 1 && b >> (H + i % H) & 1) {
        if (m[i / H][i % H] == '#') {
          if (++black > K) {
            break;
          }
        }
      }
    }
    if (black == K) {
      count++;
    }
  }
  printf("%d\\n", count);
  return 0;
}