Problem p03411 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n; i >= 0; i--)
#define REP(i, s, t) for (int i = s; i <= t; i++)
#define RREP(i, s, t) for (int i = s; i >= t; i--)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

// struct edge { int to, cap, rev; };

const int MAX_V = 101;

int V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v) {
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i], w = match[u];
    if (w < 0 || !used[w] && dfs(w)) {
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bipartite_matching() {
  int res = 0;
  memset(match, -1, sizeof(match));
  for (int v = 0; v < V; v++) {
    if (match[v] < 0) {
      memset(used, 0, sizeof(used));
      if (dfs(v)) {
        res++;
        // dump(v);
      }
    }
  }
  return res;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> V;
  int n = V;
  V *= 2;
  int x1[n], y1[n];
  int x2[n], y2[n];
  rep(i, n) cin >> x1[i] >> y1[i];
  rep(i, n) cin >> x2[i] >> y2[i];
  // cout << endl;
  rep(i, n) {
    rep(j, n) {
      if (x1[i] < x2[j] && y1[i] < y2[j]) {
        add_edge(i, j + n);
        // cout << i << " " << j + n << endl;
      }
    }
  }
  // cout << endl;
  cout << bipartite_matching() << endl;

  return 0;
}


Fixed submission:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n; i >= 0; i--)
#define REP(i, s, t) for (int i = s; i <= t; i++)
#define RREP(i, s, t) for (int i = s; i >= t; i--)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

// struct edge { int to, cap, rev; };

const int MAX_V = 202;

int V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v) {
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i], w = match[u];
    if (w < 0 || !used[w] && dfs(w)) {
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bipartite_matching() {
  int res = 0;
  memset(match, -1, sizeof(match));
  for (int v = 0; v < V; v++) {
    if (match[v] < 0) {
      memset(used, 0, sizeof(used));
      if (dfs(v)) {
        res++;
        // dump(v);
      }
    }
  }
  return res;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> V;
  int n = V;
  V *= 2;
  int x1[n], y1[n];
  int x2[n], y2[n];
  rep(i, n) cin >> x1[i] >> y1[i];
  rep(i, n) cin >> x2[i] >> y2[i];
  // cout << endl;
  rep(i, n) {
    rep(j, n) {
      if (x1[i] < x2[j] && y1[i] < y2[j]) {
        add_edge(i, j + n);
        // cout << i << " " << j + n << endl;
      }
    }
  }
  // cout << endl;
  cout << bipartite_matching() << endl;

  return 0;
}