1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int n, m, q;

bool tab[59][59];
bool adj[2509][2509];
bool vis[2509];
int match[2509];

bool bpm(int u) {
    for(int v = 1; v <= n*n; v++) {
        if(adj[u][v] and not vis[v]) {
            vis[v] = true;
            if(match[v] == 0 or bpm(match[v])) {
                match[v] = u;
                return true;
            }
        }
    }
    return false;
}

int maxbpm() {
    fill(match, match + n*n, 0);
    int res = 0;
    for(int u = 1; u <= n*n; u++) {
        fill(vis, vis + n*n, false);
        if(bpm(u))
            res++;
    }
    return res;
}

void setupadj() {
    for(int i = 1; i <= n*n; i++)
        fill(adj[i], adj[i] + n*n, false);

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            if(tab[i][j]) {
                for(int t = 1; t <= n; t++) {
                    if(not tab[i][t])
                        adj[(i-1)*n+j][(i-1)*n+t] = true;
                    if(not tab[t][j])
                        adj[(i-1)*n+j][(t-1)*n+j] = true;
                }
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m >> q;
    for(int i = 0; i < m; i++) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        for(int i = x1; i <= x2; i++) {
            for(int j = y1; j <= y2; j++) {
                tab[i][j] ^= 1;
            }
        }
    }
    setupadj();
    int res = maxbpm();
    cout << res << "\n";
    for(int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        tab[x][y] ^= 1;
        setupadj();
        int res = maxbpm();
        cout << res << "\n";
    }
    
    return 0;
}