t dfs(quadtree *p,int num) { if(p==NULL)return 0; int sum=0; if(p->num)sum+=num; for(int i=0; i<4; i++) { sum+=dfs(p->next[i],num/4); } return sum; } int main() { //freopen("in.txt","r",stdin); quadtree *root1,*root2,*root; scanf("%d",&T); while(T--) { scanf("%s%s",s1,s2); root=root1=root2=NULL; root1=build(s1); root2=build(s2); root=merge_(root1,root2); printf("There are %d black pixels.\n",dfs(root,1024)); } return 0; }
|