Official algorithmic problem description and constraints.
There is an πΓπ grid of white and black squares. In one operation, you can select any two squares of the same color, and color all squares in the subrectangle between them that color.
Formally, if you select positions (π₯1,π¦1) and (π₯2,π¦2), both of which are currently the same color c, set the color of all (π₯,π¦) where min(π₯1,π₯2)β€π₯β€max(π₯1,π₯2) and min(π¦1,π¦2)β€π¦β€max(π¦1,π¦2) to π.
This diagram shows a sequence of two possible operations on a grid:

Is it possible for all squares in the grid to be the same color, after performing any number of operations (possibly zero)?
Detailed video explanations, mathematical intuition, and clean C++ implementation code.