Language: C++

#include <iostream>
#include <queue>
#include <vector>

#define MAX_V 1000

using namespace std;

// quoted from "Programming Contest Challenge Book" (Takuya Akiba)
struct edge {
    int to;
    int cap;
    int rev;
};

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from, int to, int cap) {
    // 正方向のedge 負方向のedgeのitを追加 (次の行でpush_backされる要素のitはsize())
    G[from].push_back((edge){to, cap, (int)(G[to].size())});

    // 負方向のedge capacity = 0, (前の行でpush_backされた要素のitはsize() - 1)
    G[to].push_back((edge){from, 0, (int)(G[from].size() - 1)});
}

// sからの最短距離をBFSで計算する
void bfs(int s) {
    memset(level, -1, sizeof(level));
    queue<int> que;

    // s->sの距離は0
    level[s] = 0;
    que.push(s);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        // vに接続されている全てのエッジe
        for (auto& e : G[v]) {
            // まだ流せる && 未到達
            // (幅優先なので，後ろの訪問で，よりlevelが小さくなることはない)
            if (e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

int dfs(int v, int t, int f) {
    if (v == t) return f;

    for (int& i = iter[v]; i < G[v].size(); ++i) {
        edge& e = G[v][i];
        // まだ流せる && パスをたどる経路
        if (e.cap > 0 && level[v] < level[e.to]) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }

    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;

    while (true) {
        bfs(s);
        if (level[t] < 0) {
            // 増加パスで，tに到達可能なものがない
            return flow;
        }
        memset(iter, 0, sizeof(iter));
        int f;
        while ((f = dfs(s, t, 1 << 30)) > 0) flow += f;
    }
}

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

int main(void) {
    int N;
    cin >> N;
    int source = 2 * N;
    int sink = 2 * N + 1;

    vector<pair<int, int>> red, blue;

    REP(i, N) {
        int a, b;
        cin >> a >> b;
        red.emplace_back(a, b);
    }

    REP(i, N) {
        int a, b;
        cin >> a >> b;
        blue.emplace_back(a, b);
    }

    REP(i, N) {
        REP(j, N) {
            if (red[i].first < blue[j].first && red[i].second < blue[j].second) {
                add_edge(i, N + j, 1);
            }
        }
    }

    REP(i, N) {
        add_edge(source, i, 1);
        add_edge(i + N, sink, 1);
    }

    cout << max_flow(source, sink) << endl;

    return 0;
}


Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:30:5: error: 'memset' was not declared in this scope
   30 |     memset(level, -1, sizeof(level));
      |     ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <queue>
  +++ |+#include <cstring>
    3 | #include <vector>
a.cc: In function 'int max_flow(int, int)':
a.cc:81:9: error: 'memset' was not declared in this scope
   81 |         memset(iter, 0, sizeof(iter));
      |         ^~~~~~
a.cc:81:9: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'