Test instructions: Find the number of black pixels after merging the two four-minute trees.
Analysis: The edge of the achievement side statistics.
#include <cstdio>#include<cstring>#include<cstdlib>#include<cctype>#include<cmath>#include<iostream>#include<sstream>#include<iterator>#include<algorithm>#include<string>#include<vector>#include<Set>#include<map>#include<stack>#include<deque>#include<queue>#include<list>typedefLong Longll;typedef unsignedLong LongLlu;Const intInt_inf =0x3f3f3f3f;Const intInt_m_inf =0x7f7f7f7f;Constll ll_inf =0x3f3f3f3f3f3f3f3f;Constll ll_m_inf =0x7f7f7f7f7f7f7f7f;Const intDr[] = {0,0, -1,1};Const intDc[] = {-1,1,0,0};Const DoublePI = ACOs (-1.0);Const DoubleEPS = 1e-8;Const intMAXN =1100+Ten;Const intMaxt = ++Ten;using namespacestd;CharS[MAXN];intVis[maxt][maxt];intCNT;voidDfsint&id,intRintCintLen) { CharCC = s[id++];//to participate in self-increment, traverse each element if(CC = ='P') {DFS (ID, R, c+ Len/2, Len/2);//1DFS (ID, R, c, Len/2);//2DFS (ID, r + len/2, C, Len/2);//3DFS (ID, r + len/2, C + Len/2, Len/2);//4 } Else if(CC = ='F'){ for(inti = r; I < R + len; ++i) { for(intj = C; J < C + Len; ++j) { if(!Vis[i][j]) {Vis[i][j]=1; ++CNT; } } } }}intMain () {intT; scanf ("%d", &T); while(t--) {memset (Vis,0,sizeofvis); CNT=0; for(inti =0; I <2; ++i) {scanf ("%s", s); intID =0; DFS (ID,0,0, +); } printf ("There is%d black pixels.\n", CNT); } return 0;}
UVA-297 quadtrees (four min tree)