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
#include <bits/stdc++.h>
using namespace std;
const int N=2002;
int pref[N][N], t[N][N], X[N], Y[N], cntx, cnty, total;
int n, m, q;

void ans(){
int a=total-(cntx*cnty);
int b=n*n-total;
cout<<min(a, b)<<'\n';
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>q;
    while(m--){
        int x1, y1, x2, y2;
        cin>>x1>>y1>>x2>>y2;
        pref[x1][y1]++;
        pref[x2+1][y1]--;
        pref[x1][y2+1]--;
        pref[x2+1][y2+1]++;
    }
    for(int i=1; i<=n; ++i){
        for(int j=1; j<=n; ++j){
            pref[i][j]+=(pref[i][j-1]+pref[i-1][j]-pref[i-1][j-1]);
        }
    }

    for(int i=1; i<=n; ++i){
        int sum=0;
        for(int j=1; j<=n; ++j){
            pref[i][j]%=2;
            sum+=pref[i][j];
        }
        X[i]=sum;
        if(sum==n)cntx++;
        total+=sum;
    }
    for(int i=1; i<=n; ++i){
        int sum=0;
        for(int j=1; j<=n; ++j) sum+=pref[j][i];
        Y[i]=sum;
        if(sum==n) cnty++;
    }
    ans();
    while(q--){
        int x, y;
        cin>>x>>y;
        if(pref[x][y]==0){
            pref[x][y]=1;
            total++;
            X[x]++;
            Y[y]++;
            if(X[x]==n) cntx++;
            if(Y[y]==n) cnty++;
        }
        else{
            pref[x][y]=0;
            total--;
            if(X[x]==n) cntx--;
            if(Y[y]==n) cnty--;
            X[x]--;
            Y[y]--;
        }
        ans();
    }


    return 0;
}