Editorial for Mock CCC '19 Contest 1 S2 - Pusheen's Puzzle Present
Submitting an official solution before solving the problem yourself is a bannable offence.
This problem is a homage to CCC 2018 S2, which tripped up competitors who had difficulty with rotating two-dimensional arrays.
For the first subtask, the answer is guaranteed to be 2.
For the second subtask, the answer is 3 if and only if the center element of the array is equal to 5. Otherwise, it is equal to 2.
For the third subtask, a brute force solution that attempted to rotate every valid subgrid would have worked.
To get full credit, the critical observation to make is that the corners of the subgrid are guaranteed to be different. As a result, it sufficed to compute the bounding box of all elements that were not where they should have been, and return the size of the bounding box.