计算上下左右的控制的方向的问题,C语言的程序的代码的技术的编写的设计的思想的方法的技术

Problem Description
Soko-ban is a Japanese word for a warehouse worker, and the name of a classic computer game created in the 1980s. It is a one-player game with the following premise. A single worker is in an enclosed warehouse with one or more boxes. The goal is to move those boxes to a set of target locations, with the number of target locations equalling the number of boxes. The player indicates a direction of motion for the worker using the arrow keys (up, down, left, right), according to the following rules.
1.If the indicated direction of motion for the worker leads to an empty location (i.e., one that does not have a box or wall), the worker advances by one step in that direction.
2.If the indicated direction of motion would cause the worker to move into a box, and the location on the other side of the box is empty, then both the worker and the box move one spot in that direction (i.e., the worker pushes the box).
3.If the indicated direction of motion for a move would cause the worker to move into a wall, or to move into a box that has another box or a wall on its opposite side, then no motion takes place for that keystroke.
The goal is to simultaneously have all boxes on the target locations. In that case, the player is successful (and as a formality, all further keystrokes will be ignored).
The game has been studied by computer scientists (in fact, one graduate student wrote his entire Ph.D. dissertation about the analysis of sokoban). Unfortunately, it turns out that finding a solution is very difficult in general, as it is both NP-hard and PSPACE-complete. Therefore, your goal will be a simpler task: simulating the progress of a game based upon a player's sequence of keystrokes. For the sake of input and output, we describe the state of a game using the following symbols:

For example, the initial configuration diagrammed at the beginning of this problem appears as the first input case below.

Input
Each game begins with a line containing integers R and C, where 4 ≤ R ≤ 15 represents the number of rows, and 4 ≤ C ≤ 15 represents the number of columns. Next will be R lines representing the R rows from top to bottom, with each line having precisely C characters, from left-to-right. Finally, there is a line containing at most 50 characters describing the player's sequence of keystrokes, using the symbols U, D, L, and R respectively for up, down, left, and right. You must read that entire sequence from the input, even though a particular game might end successfully prior to the end of the sequence. The data set ends with the line 0 0.
We will guarantee that each game has precisely one worker, an equal number of boxes and locations, at least one initially misplaced box, and an outermost boundary consisting entirely of walls.

Output
For each game, you should first output a line identifying the game number, beginning at 1, and either the word complete or incomplete, designating whether or not the player successfully completed that game. Following that should be a representation of the final board configuration.

Sample Input
8 9
#########
#...#...#
#..bb.b.#
#...#w#.#
#...#b#.#
#...++++#
#...#..##
#########
ULRURDDDUULLDDD
6 7
#######
#..####
#.+.+.#
#.bb#w#
##....#
#######
DLLUDLULUURDRDDLUDRR
0 0

Sample Output
Game 1: incomplete
#########
#...#...#
#..bb...#
#...#.#.#
#...#.#.#
#...+W+B#
#...#b.##
#########
Game 2: complete
#######
#..####
#.B.B.#
#.w.#.#
##....#
#######

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

1
c#中用上下左右键控制在控制台界面任意位置显示“Hello World”
0
图上的边的直径的计算的算法问题,怎么利用C语言的程序的代码的计算的方式?
0
C语言程序计算最大可以获取的积分的问题,怎么编写程序的代码的方式具体的实现的?
0
计算时间间隔的一个算法的求解问题,怎么利用C语言的程序代码编写的方式实现这个程序的计算的?
0
家用电器的功率的计算的应用问题的算法,怎么使用C语言的程序的代码编写的技术实现的程序呢?
0
小朋友的寻找座位的游戏的程序计算问题,怎么利用C语言的设计思想来编写代码计算的
0
计算残影占用的字符的位置问题,是如何通过运用C语言的程序的代码编写的技术的方式去解决的
0
射线和圆的相交的计算的问题,是如何利用C语言的程序的代码的编写的技术的方式实现的
0
数字的改变的次数的计算问题,怎么利用C语言的程序的代码编写的技术的手段实现的
1
计算楼梯的攀登的问题是怎么用C语言的程序的代码的编写的思想的方法有效地加以实现解决的呢?
0
如何利用C语言的程序编写的思想解决这里的罗马数字的问题的计算的,代码的思想
0
根据年份计算是否下雨的概率问题,是如何利用C语言的程序编写程序的代码设计思想的方法计算的
0
计算斐波拉契数列的区间和的问题,要求计算大数的方式实现怎么用的C语言的程序编写代码的形式的思路
0
USTC的校园网络的计算问题,怎么使用C语言的程序代码编写技术运用的代码编写的计是什么
0
小白计算最大的网格的高度问题,怎么采用C语言的程序编写的代码的形式的方式来解决的
0
用文件计算警察追小偷的问题,怎么采用C语言的程序的代码的运用的技术去编写代码的
0
儿童的猫狗比较的问题计算的是人数,怎么用C语言的程序的编写的过程的设计的惯例来编写的代码
0
区间内的最大值的计算的问题是怎么利用C语言的程序的编写的代码的设计的技术办法来实现的呢?
0
计算运动的水平和垂直方向的速度的问题,怎么使用C语言的程序的代码设计思想的过程来解决?
0
计算反射的角度的问题的一个算法,怎么用C语言的程序的设计的技术怎么用代码实现的