P7007 [CERC2013] Rubik's Rectangle

题目描述

A new puzzle which aims to conquer the game market is a fusion of Rubik's Cube and Fifteen. The board is an $H \times W$ frame with tiles with all numbers from $1$ to $H · W$ printed on them. ![](/upload/images2/rubik1.png) The only type of move that is allowed is flipping either one of the rows or one of the columns. Flipping reverses the order of the row's (or column's) elements. Below the third row is flipped: ![](/upload/images2/rubik2.png) You are given a board with tiles numbered in some arbitrary order. Determine a sequence of flips that brings the board to the nicely sorted position, if possible. ![](/upload/images2/rubik3.png)

输入格式

输出格式

说明/提示

Time limit: 6 s, Memory limit: 128 MB.