Problem:
Score : 300 points

Problem Statement

Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.

Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.

Here, both the x- and y-coordinates before and after each movement must be integers.

He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).

Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).

Under this condition, find a shortest path for him.

Constraints

-1000 ≤ sx < tx ≤ 1000

-1000 ≤ sy < ty ≤ 1000

sx,sy,tx and ty are integers.

Input

The input is given from Standard Input in the following format:

sx sy tx ty

Output

Print a string S that represents a shortest path for Dolphin.

The i-th character in S should correspond to his i-th movement.

The directions of the movements should be indicated by the following characters:

U: Up

D: Down

L: Left

R: Right

If there exist multiple shortest paths under the condition, print any of them.

Sample Input 1

0 0 1 2

Sample Output 1

UURDDLLUUURRDRDDDLLU

One possible shortest path is:

Going from (sx,sy) to (tx,ty) for the first time: (0,0) → (0,1) → (0,2) → (1,2)

Going from (tx,ty) to (sx,sy) for the first time: (1,2) → (1,1) → (1,0) → (0,0)

Going from (sx,sy) to (tx,ty) for the second time: (0,0) → (-1,0) → (-1,1) → (-1,2) → (-1,3) → (0,3) → (1,3) → (1,2)

Going from (tx,ty) to (sx,sy) for the second time: (1,2) → (2,2) → (2,1) → (2,0) → (2,-1) → (1,-1) → (0,-1) → (0,0)

Sample Input 2

-2 -2 1 1

Sample Output 2

UURRURRDDDLLDLLULUUURRURRDDDLLDL

Solution in Rust (1.15.1) (judge verdict: Accepted)

#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let (sx, sy, tx, ty): (isize, isize, isize, isize);
    input!(sx, sy, tx, ty);
    let (mut x, mut y) = (sx, sy);
    let mut stage = 0;

    while stage != 8 {
        if stage == 0 {
            //txへ向かう
            if x == tx {
                stage += 1;
            } else if x < tx {
                print!("R");
                x += 1;
            } else {
                print!("L");
                x -= 1;
            }
        } else if stage == 1 {
            //tyへ向かう
            if y == ty {
                stage += 1;
            } else if y < ty {
                print!("U");
                y += 1;
            } else {
                print!("D");
                y -= 1;
            }
        } else if stage == 2 {
            //sxへ向かう
            if x == sx {
                stage += 1;
            } else if x < sx {
                print!("R");
                x += 1;
            } else {
                print!("L");
                x -= 1;
            }
        } else if stage == 3 {
            //syへ向かう
            if y < sy {
                print!("U");
                y += 1;
                if y == sy {
                    print!("U");
                    y += 1;
                    stage += 1;
                }
            } else {
                print!("D");
                y -= 1;
                if y == sy {
                    print!("D");
                    y -= 1;
                    stage += 1;
                }
            }
        } else if stage == 4 {
            //tx+1 or tx-1へ向かう
            if x < tx {
                print!("R");
                x += 1;
                if x == tx {
                    x += 1;
                    print!("R");
                    stage += 1;
                }
            } else {
                print!("L");
                x -= 1;
                if x == tx {
                    x -= 1;
                    print!("L");
                    stage += 1;
                }
            }
        } else if stage == 5 {
            //tyへ向かう
            if y < ty {
                print!("U");
                y += 1;
                if y == ty {
                    y += 1;
                    x -= 1;
                    print!("LU");
                    stage += 1;
                }
            } else {
                print!("D");
                y -= 1;
                if y == ty {
                    x += 1;
                    y -= 1;
                    print!("RD");
                    stage += 1;
                }
            }
        } else if stage == 6 {
            //sx-1 or sx+1へ向かう
            if x < sx {
                print!("R");
                x += 1;
                if x == sx {
                    x += 1;
                    print!("R");
                    stage += 1;
                }
            } else {
                print!("L");
                x -= 1;
                if x == sx {
                    x -= 1;
                    print!("L");
                    stage += 1;
                }
            }
        } else if stage == 7 {
            //syへ向かう
            if y < sy {
                print!("U");
                y += 1;
                if y == sy {
                    x += 1;
                    print!("L");
                    stage += 1;
                }
            } else {
                print!("D");
                y -= 1;
                if y == sy {
                    x -= 1;
                    print!("R");
                    stage += 1;
                }
            }
        }
    }
    println!("");
}