Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.3 kB
2
Indexable
Never
#include <bits/stdc++.h>

using namespace std;

ifstream fin("plaja1.in");
ofstream fout("plaja1.out");

int a, b, u, x, y, x_1, x_2, y_1, y_2, m, n, ans1, ans2, v[2005][2005], cn, cm, cx, s[2005][2005];

void solve(){
    
    fin>>a>>b>>u;
    
    while(u--){
        fin>>x>>y;
        v[x][y]=1;
        s[x][y]=1;
    }
    
    for(int i=1; i<=a; i++){
        for(int j=1; j<=b; j++){
            v[i][j]=v[i-1][j]+v[i][j-1]-v[i-1][j-1]+v[i][j];
        }
    }
    
    fin>>n;

    while(n--){
        fin>>x_1>>y_1>>x_2>>y_2;
        cx=v[x_2][y_2]-v[x_1-1][y_2]-v[x_2][y_1-1]+v[x_1-1][y_1-1];
        s[x_1][y_1]+=1;
        s[x_1][y_2+1]-=1;
        s[x_2+1][y_1]-=1;
        s[x_2+1][y_2+1]+=1;
        if(cx==0){
            ans1++;
        }
    }
    
    for(int i=1; i<=a; i++){
        for(int j=1; j<=b; j++){
            s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+s[i][j];
        }
    }
    
    fin>>m;
    
    while(m--){
        fin>>x_1>>y_1>>x_2>>y_2;
        cx=s[x_2][y_2]-s[x_1-1][y_2]-s[x_2][y_1-1]+s[x_1-1][y_1-1];
        int cy=v[x_2][y_2]-v[x_1-1][y_2]-v[x_2][y_1-1]+v[x_1-1][y_1-1];
        if(cx==0 && cy==0){
            ans2++;
        }
    }
    
    fout<<ans1<<" "<<ans2;
}

int main(){
    solve();
    return 0;
}