几何图形的碰撞的一个判断的算法,怎么采用C语言的程序的代码的编写的思路去实现的呢?

Problem Description
PusherBoy is an online game http://www.hacker.org/push . There is an R * C grid, and there are piles of blocks on some positions. The goal is to clear the blocks by pushing into them.

You should choose an empty area as the initial position of the PusherBoy. Then you can choose which direction (U for up, D for down, L for left and R for right) to push. Once the direction is chosen, the PusherBoy will walk ahead until he met a pile of blocks (Walking outside the grid is invalid). Then he remove one block from the pile (so if the pile contains only one block, it will become empty), and push the remaining pile of blocks to the next area. (If there have been some blocks in the next area, the two piles will form a new big pile.)

Please note if the pusher is right up against the block, he can't remove and push it. That is, there must be a gap between the pusher and the pile. As the following figure, the pusher can go up, but cannot go down. (The cycle indicates the pusher, and the squares indicate the blocks. The nested squares indicate a pile of two blocks.)

And if a whole pile is pushed outside the grid, it will be considered as cleared.

Input
There are several test cases in each input. The first two lines of each case contain two numbers C and R. (R,C <= 25) Then R lines follow, indicating the grid. '.' stands for an empty area, and a lowercase letter stands for a pile of blocks. ('a' for one block, 'b' for two blocks, 'c' for three, and so on.)

Output
Output three lines for each case. The first two lines contains two numbers x and y, indicating the initial position of the PusherBoy. (0 <= x < R, 0 <= y < C). The third line contains a moving sequence contains 'U', 'D', 'L' and 'R'. Any correct answer will be accepted.

Sample Input
3
7
...
...
.b.
...
...
.a.
...

Sample Output
4
1
UDU

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

相似问题

1
关于如何计算机IP地址的判断判定算法C语言
1
采用C语言解决这个距离远近的长短的判断的算法怎么实现?具体的思路谢谢
1
数据结构上的一个线性表的冲突的解决,是不是用哈希算法怎么采用C语言的实现方式
1
物体碰撞和反弹消除的判断,采用C语言解决这个算法怎么实现思路
0
顺序重排的算法的问题,输出可行性判断,采用C语言的算法思路的实现
0
曲线线段距离求和算法的一个判断,采用C语言编程语言的实现的方式
0
连续的数字的一个判断的算法问题,问题采用C语言最佳的做法是怎么实现的
0
圆面上的扇形和环的切割几何问题的一个算法,采用C语言编程怎么才能比较好的实现
0
分项的条件的判断的一个算法的问题,如何利用C语言的方式解决的
0
纸牌牌面正反的判断问题的算法,怎么采用C语言程序设计的办法来实现的
1
拍卖竞价的一个应用题的算法的实现,怎么采用C语言的程序的设计的形式来实现的呢
0
循环跳跃数的一个输出问题的算法,怎么采用C语言的程序的方式来实现
0
真假数的序列的一个判断的算法,怎么用C语言的程序的设计的方式实现
0
碰撞的计算的算法的问题,怎么利用C语言的程序的设计的方式来实现的?
0
六位数字的编码的一个日期的算法,采用C语言的程序的设计的过程的做法
0
稀疏矩阵的一个判断的算法,如何利用C语言的程序的编写的办法去实现的?
0
坐标图形的遮挡判断的一个算法的问题,如何利用C语言的程序编写的方式去实现的?
0
反推递增数列的一个算法的思路问题,怎么采用C语言的程序的设计的思想实现?
0
和最短路经有关的一个时间的算法的运用,怎么采用C语言的程序的编写的过程去实现的
0
数组的平均切分的一个算法,怎么采用C语言的程序的编写的过程的方式怎么实现?