##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
| # | Title | Points | Solved | Admin | |
|---|---|---|---|---|---|
You are given an grid . Each integer from to appears exactly once in the grid.
The sorted grid is the grid where for every .
You may apply the following operation any number of times:
Choose two integers and such that and . Then, inside the subgrid with top-left cell , simultaneously do both swaps:
For each test case, determine whether it is possible to transform the given grid into the sorted grid.
The grid is already sorted.
The grid is already sorted, so no operation is needed.
For a 2 by 2 grid, the only operation swaps both diagonals at the same time. This grid swaps only one diagonal compared to the sorted grid, so it cannot be sorted.
It can be sorted by applying operations with top-left cells (1,1), (2,2), (1,1), and (2,2).
The values 1 and 2 are placed on cells with different parity from where they must end up, and the operation cannot change this parity for a value.