{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"Imagine you are standing inside a two-dimensional maze composed of square cells which may or may not be filled with rock. You can move north, south, east or west one cell at a step. These moves are called walks. \n\u003cbr\u003eOne of the empty cells contains a box which can be moved to an adjacent free cell by standing next to the box and then moving in the direction of the box. Such a move is called a push. The box cannot be moved in any other way than by pushing, which means that if you push it into a corner you can never get it out of the corner again. \n\u003cbr\u003e\n\u003cbr\u003eOne of the empty cells is marked as the target cell. Your job is to bring the box to the target cell by a sequence of walks and pushes. As the box is very heavy, you would like to minimize the number of pushes. Can you write a program that will work out the best such sequence?\n\u003cbr\u003e\u003ccenter\u003e\u003cimg src\u003d\"CDN_BASE_URL/96148a04383d9fe2630a3ac772f12261?v\u003d1688147491\"\u003e\u003c/center\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input contains the descriptions of several mazes. Each maze description starts with a line containing two integers r and c (both \u0026lt;\u003d 20) representing the number of rows and columns of the maze. \n\u003cbr\u003e\n\u003cbr\u003eFollowing this are r lines each containing c characters. Each character describes one cell of the maze. A cell full of rock is indicated by a `#\u0027 and an empty cell is represented by a `.\u0027. Your starting position is symbolized by `S\u0027, the starting position of the box by `B\u0027 and the target cell by `T\u0027. \n\u003cbr\u003e\n\u003cbr\u003eInput is terminated by two zeroes for r and c. \n\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each maze in the input, first print the number of the maze, as shown in the sample output. Then, if it is impossible to bring the box to the target cell, print ``Impossible.\u0027\u0027. \n\u003cbr\u003e\n\u003cbr\u003eOtherwise, output a sequence that minimizes the number of pushes. If there is more than one such sequence, choose the one that minimizes the number of total moves (walks and pushes). If there is still more than one such sequence, any one is acceptable. \n\u003cbr\u003e\n\u003cbr\u003ePrint the sequence as a string of the characters N, S, E, W, n, s, e and w where uppercase letters stand for pushes, lowercase letters stand for walks and the different letters stand for the directions north, south, east and west. \n\u003cbr\u003e\n\u003cbr\u003eOutput a single blank line after each test case. \n\u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1 7\nSB....T\n1 7\nSB..#.T\n7 11\n###########\n#T##......#\n#.#.#..####\n#....B....#\n#.######..#\n#.....S...#\n###########\n8 4\n....\n.##.\n.#..\n.#..\n.#.B\n.##S\n....\n###T\n0 0\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eMaze #1\nEEEEE\n\nMaze #2\nImpossible.\n\nMaze #3\neennwwWWWWeeeeeesswwwwwwwnNN\n\nMaze #4\nswwwnnnnnneeesssSSS\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","value":{"format":"HTML","content":"想象一下,你站在一个二维的迷宫里,由方形的格子组成,可能有或者没有被岩石充满。你可以在一个格子上向北、南、东或西移动。这些动作叫做步行。 其中一个空格子包含一个盒子,它可以通过站在盒子旁边,然后在盒子的方向上移动,移动到相邻的空格子。这样的动作叫做推。这个盒子不能用任何其他方式来移动,这意味着如果你把它推到角落里,你就再也不能把它从角落里拿出来。\n\n其中一个空格子被标记为目标格子。你的工作是把箱子放在目标格子中,通过一系列的行走和推动。由于箱子很重,你想把推的数量减到最少。你能写出一个程序来找出最好的顺序吗?\n\n想象一下,你站在一个二维的迷宫里,由方形的格子组成,可能有或者没有被岩石充满。你可以在一个格子上向北、南、东或西移动。这些动作叫做步行。 其中一个空格子包含一个盒子,它可以通过站在盒子旁边,然后在盒子的方向上移动,移动到相邻的空格子。这样的动作叫做推。这个盒子不能用任何其他方式来移动,这意味着如果你把它推到角落里,你就再也不能把它从角落里拿出来。\n\n\u003cbr\u003e\n\n其中一个空格子被标记为目标格子。你的工作是把箱子放在目标格子中,通过一系列的行走和推动。由于箱子很重,你想把推的数量减到最少。你能写出一个程序来找出最好的顺序吗?\n\n\n\u003cbr\u003e\n\u003cbr\u003e\n输入\n\n\u003cbr\u003e\n输入包含几个迷宫的描述。每个迷宫描述都包含一个包含两个整数R和C的线段( R,C\u003c\u003d20),表示迷宫的行数和列数。\n\n下面是每个包含C字符的R行。每个字符描述迷宫中的一个单元。一个岩石的格子是由一个\u0027#\u0027表示的,一个空的格子由一个\u0027.\u0027表示。你的起始位置用“S”表示,方框的开始位置由“B”和目标格子按“T”表示。\n\n输入R,C为0 0结束。\n\n\u003cbr\u003e\n\n\u003cbr\u003e\n输出\n\n\u003cbr\u003e\n对于每一个迷宫中的输入,首先打印迷宫的数目,如样本输出所示。然后,如果不可能把盒子带到目标单元格,打印\"Impossible.\"。\n\n否则,输出一个最小化推送次数的序列。如果有不止一个这样的序列,那么选择一个最小化总移动次数(步行和推送)的序列。如果仍然有不止一个这样的序列,任何一个都是可以接受的。\n\n将序列打印为字符N、S、E、W、n、s、e和w的字符串,其中大写字母代表推,小写字母代表行走,不同字母代表南北、南、东和西的方向。\n\n在每个测试用例之后输出一个空行。\n"}}]}