3A.md (1548B)
1 Source: https://codeforces.com/problemset/problem/3/A 2 3 A. Shortest path of the king 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 64 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, because he has business of national importance. For example, he has to pay an official visit to square *t*. As the king is not in habit of wasting his time, he wants to get from his current position *s* to square *t* in the least number of moves. Help him to do this. 22 23  24 25 In one move the king can get to the square that has a common side or a common vertex with the square the king is currently in (generally there are 8 different squares he can move to). 26 27 Input 28 29 The first line contains the chessboard coordinates of square *s*, the second line — of square *t*. 30 31 Chessboard coordinates consist of two characters, the first one is a lowercase Latin letter (from a to h), the second one is a digit from 1 to 8. 32 33 Output 34 35 In the first line print *n* — minimum number of the king's moves. Then in *n* lines print the moves themselves. Each move is described with one of the 8: L, R, U, D, LU, LD, RU or RD. 36 37 L, R, U, D stand respectively for moves left, right, up and down (according to the picture), and 2-letter combinations stand for diagonal moves. If the answer is not unique, print any of them. 38 39 Examples 40 41 Input 42 43 ``` 44 a8 45 h1 46 ``` 47 48 Output 49 50 ``` 51 7 52 RD 53 RD 54 RD 55 RD 56 RD 57 RD 58 RD 59 ```