let a be the acceleration of blocks. Figure shows the coordinate system considered to get componenets.
Block of mass m1 moves in x-axis direction, hence its acceleration is only in x-direction.
Similarly block of mass m2 moves only in y-direction and its acceleration is only in y-direction.
X-component of acceleration of Centre of mass, axcm , where is unit vector along x-direction
Similarly, Y-component of acceleration of Centre of mass, aycm , where is unit vector along y-direction