Official algorithmic problem description and constraints.
You are given two grids of numbers π and π, with π rows and π columns. All the values in the grid are 0, 1 or 2.
You can perform the following operation on π any number of times:
Note that the operation only changes the values of the corners of the picked subrectangle.
Is it possible to convert the grid π into grid π by applying the above operation any number of times (possibly zero)?
Detailed video explanations, mathematical intuition, and clean C++ implementation code.