a problem i am facing

Revision en1, by zarif_2002, 2018-11-24 15:08:56

how can i solve #524C(div 2) without using adjacency matrix as i cannot form adjacency matrix due to large size of array

include<stdio.h>

int main(){

int l,r,n,m,i,j,x1,y1,x2,y2,x3,y3,x4,y4,s1,s2;

char a[1000000002][1000000002];

scanf("%d",&l);

for(r = 0; r < l; r++){

    scanf("%d %d",&n,&m);

    scanf("%d %d %d %d",&x1,&y1,&x2,&y2);

    scanf("%d %d %d %d",&x3,&y3,&x4,&y4);

    s1 = 0, s2 = 0;

    for(i = 1; i <= m; i++){

        for(j = 1; j <= n; j++){

            if((i + j) %2 == 0){

                a[i][j] = '0';/*white*/
            }
            else{

                a[i][j] = '1';/*black*/
            }
        }
    }
    for(i = x1; i <= x2; i++){

        for(j = y1; j <= y2; j++){

            a[i][j] = '0';
        }
    }
    for(i = x3; i <= x4; i++){

        for(j = y3; j <= y4; j++){

            a[i][j] = '1';
        }
    }
    for(i = 1; i <= m; i++){

        for(j = 1; j <= n; j++){

            if(a[i][j] == '0'){

                s1++;
            }
            else{

                s2++;
            }
        }
    }
    printf("%d %d\n",s1,s2);
}
return 0;

}

Tags #implementation

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English zarif_2002 2018-11-24 15:08:56 1374 Initial revision (published)