#SDNU1220. Look for homework
Look for homework
Description
(the picture has no relation with this problem..I just want to add a picture. emmm..)
Super scholar robs the all homework of others. The monitor decides to combat with the super scholar so as to help students to get back the homework. But super scholar lives in a castle because he doesn't want to be disturbed. The outside of the castle is a maze with two dimension grids. Entering the castle must pass the maze. The monitor needs to save time because of accompanying his girlfriend, so he wants to make a student named Huachao Wei help him who hasn't a girlfriend. Now he has the map of the maze and needs to calculate the shortest path.
Format
Input
The input consists several cases.For each case starts with two integers ,symbolizing the length and width of the maze.The next lines contain numbers with no space and value for only 0 and 1.The essence is that 0 can pass ,1 can't pass. Now you are in the place of refering to the top left corner.the export is in the place of .Each step can only walk with up,down,left and right.
Output
For each case,the first line prints the least number of steps to arrive the castle.The second line prints characters for ,representing up,down,left,right.if there are many paths with the same length,please print the path with Minimum dictionary. It is guarantees that there must have a path for arriving the castle.
Samples
3 3
001
100
110
3 3
000
000
000
4
RDRD
4
DDRR