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
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include<cstdio>
#include<algorithm>
#include<vector>
#define S 2007
using namespace std;

int T[S][S];

vector < pair < int , int > > V[S][S];
int n;
int nr = 0;
pair < int , int > partner[S][S];
int odw[S][S];
bool zablo[S][S];

bool match(int x, int y){
    odw[x][y] = nr;
    for(int i = 0 ; i < V[x][y].size();i++){
        int x1 = V[x][y][i].first;
        int y1 = V[x][y][i].second;
        if(partner[x1][y1] == make_pair(0,0)){
            partner[x1][y1] = {x,y};
            return true;
        }
    }

    for(int i = 0 ; i < V[x][y].size();i++){
        int x1 = V[x][y][i].first;
        int y1 = V[x][y][i].second;

        int x2 = partner[x1][y1].first;
        int y2 = partner[x1][y1].second;

        if(odw[x2][y2] != nr && !zablo[x2][y2]){
            if(match(x2,y2)){
                partner[x1][y1] = {x,y};
                return true;
            }else{
                zablo[x2][y2] = 1;
            }
        }

    }
    return false;

}

void odpowiedz(){
    for(int i = 1; i <= n;i++){
        for(int j = 1; j <= n;j++){
            V[i][j].clear();
            partner[i][j] = {0,0};
            odw[i][j] = 0;
            zablo[i][j] = 0;
            if(T[i][j]%2 == 1){
                for(int k = 1; k <= n;k++){
                    if(T[i][k]%2 == 0){
                        V[i][j].push_back({i,k});
                    }
                    if(T[k][j]%2 == 0){
                        V[i][j].push_back({k,j});
                    }
                }
            }
        }
    }
    nr = 0;
    int odp = 0;
    for(int i = 1; i <= n;i++){
        for(int j = 1; j <= n;j++){
            if(T[i][j]%2 == 1){
                nr++;
                if(match(i,j))
                    odp++;
            }
        }
    }


    printf("%d\n",odp);
}

int main(void){
    int m,q;
    scanf("%d %d %d",&n,&m,&q);

    int x1,x2,y1,y2;

    for(int i = 1; i <= m;i++){
        scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
        if(x1 > x2)
            swap(x1,x2);
        if(y1 > y2)
            swap(y1,y2);
        T[x1][y1]++;
        T[x2+1][y1]--;
        T[x1][y2+1]--;
        T[x2+1][y2+1]++;
    }
    for(int i = 1; i <= n;i++){
        for(int j = 1; j <= n;j++){
            T[i][j] += (T[i-1][j] + T[i][j-1] - T[i-1][j-1]);
        }
    }

    odpowiedz();
    for(int i = 1; i <= q;i++){
        scanf("%d %d",&x1,&y1);
        T[x1][y1]++;
        odpowiedz();
    }



    return 0;
}