
ZOJ Problem Set  2474
World goes round. World goes round. World goes round. Arrange n^2 numbers from 0 to n^2  1 into n*n grids. One can rotate a block of 2*2 grids clockwise like in Figure 1. A rotation is denoted by the coordinates of the upperleft corner of the block.
Your task is to rearrange, by a sequence of rotations, all the numbers from 0 to n2  1 on the grids in a sorted order from top down, left to right.
The input consists of several test cases. For each case there is a positive integer n (2 <= n <= 10) in the first line, followed by n lines that describe the rows of the board. A test case with n = 0 signals the end of input and must not be processed.
For each case, output in the following format: K where K is the number of steps taken to accomplish the task, and Si's are the names of the rotations. If the task cannot be accomplished, simply output "No". Note: If a solution exists, it will not exceed 10000 steps.
2
No
Author: ZHENG, Jianqiang Source: Zhejiang Provincial Programming Contest 2005 