Problem p02837 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <cmath>
#include <math.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;

#define rep(i, n)                                                              \
  ;                                                                            \
  for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n", a)
#define mem(a) memset(a, 0, sizeof(a))
#define f(i, a, b) for (int i = a; i < b; i++)
#define pri(a) printf("%.14lf\n", a);
#define MOD 1000000007
bool is_int_lround(double x) { return std::lround(x) == x; }
ll keta(ll x) {
  int n = 0;
  while (x > 0) {
    x /= 10;
    n++;
  }
  return n;
}

ll conbi(int n, int m) {

  cin >> n >> m;
  vector<ll> a(100);
  a[0] = 1;
  for (int i = 0; i < 14; i++) {
    a[i + 1] = a[i] * (i + 1);
  }
  return a[n] / (a[m] * a[n - m]);
}

int main() {
  int n;
  cin >> n;
  vvi x(n);
  vvi y(n);
  rep(i, n) {
    int a;
    cin >> a;
    rep(j, a) {
      int X, Y;
      cin >> X >> Y;
      x[i].push_back(X);
      y[i].push_back(Y);
    }
  }
  int ans = 0;
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    bitset<15> s(tmp);
    bool ok = true;
    rep(i, n) {

      rep(j, x[i].size()) {
        if (s.test(i)) {
          if (s.test(x[i][j]) != y[i][j]) {
            ok = false;
          }
        }
      }
    }
    if (ok) {
      int kari = s.count();
      ans = max(ans, kari);
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#include <cmath>
#include <math.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;

#define rep(i, n)                                                              \
  ;                                                                            \
  for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n", a)
#define mem(a) memset(a, 0, sizeof(a))
#define f(i, a, b) for (int i = a; i < b; i++)
#define pri(a) printf("%.14lf\n", a);
#define MOD 1000000007
bool is_int_lround(double x) { return std::lround(x) == x; }
ll keta(ll x) {
  int n = 0;
  while (x > 0) {
    x /= 10;
    n++;
  }
  return n;
}

ll conbi(int n, int m) {

  cin >> n >> m;
  vector<ll> a(100);
  a[0] = 1;
  for (int i = 0; i < 14; i++) {
    a[i + 1] = a[i] * (i + 1);
  }
  return a[n] / (a[m] * a[n - m]);
}

int main() {
  int n;
  cin >> n;
  vvi x(n);
  vvi y(n);
  rep(i, n) {
    int a;
    cin >> a;
    rep(j, a) {
      int X, Y;
      cin >> X >> Y;
      X--;
      x[i].push_back(X);
      y[i].push_back(Y);
    }
  }
  int ans = 0;
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    bitset<15> s(tmp);
    bool ok = true;
    rep(i, n) {

      rep(j, x[i].size()) {
        if (s.test(i)) {
          if (s.test(x[i][j]) != y[i][j]) {
            ok = false;
          }
        }
      }
    }
    if (ok) {
      int kari = s.count();
      ans = max(ans, kari);
    }
  }
  cout << ans << endl;
}