UVA 10085:The most distant state2014-10-11 csdn博客 shuangde800题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=110&page=show_problem&problem=1026类型: 隐式图搜索原题:The 8-puzzle is a square tray in which eight square tiles are placed. The remaining ninth square is uncovered. Each tile has a number on it. A tile that is adjacent to the blank space can be slid into that space. A game consists of a starting state and a specified goal state. The starting state can be transformed into the goal state by sliding (moving) the tiles around. The 8-puzzle problem asks you to do the transformation in minimum number of moves.

However, our current problem is a bit different. In this problem, given an initial state of the puzzle your are asked to discover a goal state which is the most distant (in terms of number of moves) of all the states reachable from the given state.InputThe first line of the input file contains an integer representing the number of test cases to follow. A blank line follows this line.Each test case consists of 3 lines of 3 integers each representing the initial state of the puzzle. The blank space is represented by a 0 (zero). A blank line follows each test case.OutputFor each test case first output the puzzle number. The next 3 lines will contain 3 integers each representing one of the most distant states reachable from the given state. The next line will contain the shortest sequence of moves that will transform the given state to that state. The move is actually the movement of the blank space represented by four directions : U (Up), L (Left), D (Down) and R (Right). After each test case output an empty line.Sample Input12 6 41 3 70 5 8Sample OutputPuzzle #18 1 57 3 64 0 2UURDDRULLURRDLLDRRULULDDRUULDDR题目大意:题目都说了是八数码问题,不同的是,这个不是求一个八数码初始状态到达目标状态的最少步数, 而是要随便走,找出走的步数最多的那个状态,不能重复。