5290: Penguins

内存限制:256 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:2 解决:1

题目描述

Lovely penguins is a tiny game in which the player controls two penguins.

The game holds in two 20×2020 \times 2020×20 grids (the left one and the right one), and each has some blocked places.

We number the grid in xthx^{th}xth row (starting from the up), ythy^{th}yth column (starting from the left) (x,y){(x,y)}(x,y).

The penguins move in four directions: up, down, left, right, exactly one step once. If its way is blocked, or it reaches the border, then this movement is omitted.

The player also moves the penguins in four directions, but the behavior of the two penguins is mirrored:
  1. L : left penguin moves to left, right penguin moves to right.
  2. R : left penguin moves to right, right penguin moves to left.
  3. U : both move upwards.
  4. D : both move downwards.
An operation can be omitted on one penguin but works on another.

The left penguin starts from (20,20){(20,20)}(20,20) and wants to move to (1,20){(1,20)}(1,20).The right penguin starts from (20,1){(20,1)}(20,1) and wants to move to (1,1){(1,1)}(1,1).If both penguin reach there destination, thay win the game.

Find out the shortest way to win the game.If there are many shortest ways to win, find the one with minimum lexicographical order(D<L<R<U).

Note: When one penguin reaches the destination and the other does not, the penguin that has reached the destination may still move out of the destination.

输入

The input consists of 20 lines, each line contains 41 characters, describing the grids, separated by a space.
'.' means the grid is empty.
'#' means the grid is blocked.

输出

Output 22 lines.
The first line contains the least number of steps to win the game.
The second line contains a string consisting of 'L','R','U','D', describing a way to win.
There may be many ways to win, output the one with minimum lexicographical order.
Then output 20 lines, describing the track of the two penguins, mark the track with character 'A', and print as input.

样例输入 复制

#................... .............##...#.
.................... .......#.....#.....#
.........#...#.#.... ...#....#...........
#........#.......... ...#..#.............
........#......#.... ..#.#......#.#.....#
......#.#..#.#....#. .......##.....##...#
....#...........#..# ....................
.##................. ...........#..#...#.
.....#.#........#.#. #.........#.#.......
.................... ..#....#..........#.
....#.#..........#.. .#.........#..#..#..
.........#.......#.. ..#.................
...#..#......#...#.. ......#.............
...........#...#.... ....................
..##..#.#....#..#... ..............#...#.
.#..#...#.#.....##.. .........#.#...#....
.#.........#........ ..............#.#...
..##.#........#...#. ##..................
....##.#............ .......#.....#......
..........##........ .#..#.#...........#.

样例输出 复制

27
LULLUURRUUUUUUULUUUUURRUUUU
#..................A A............##...#.
...................A A......#.....#.....#
.........#...#.#...A A..#....#...........
#........#.........A A..#..#.............
........#......#.AAA AA#.#......#.#.....#
......#.#..#.#...A#. .A.....##.....##...#
....#...........#A.# .A..................
.##..............A.. .A.........#..#...#.
.....#.#........#A#. #A........#.#.......
.................AA. AA#....#..........#.
....#.#..........#A. A#.........#..#..#..
.........#.......#A. A.#.................
...#..#......#...#A. A.....#.............
...........#...#..A. A...................
..##..#.#....#..#.A. A.............#...#.
.#..#...#.#.....##A. A........#.#...#....
.#.........#....AAA. AAA...........#.#...
..##.#........#.A.#. ##A.................
....##.#........AAA. AAA....#.....#......
..........##......AA A#..#.#...........#.

提示


It's guaranteed that there always exists a way to win, and the penguins' initial position is not blocked.