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



Sample input:
0 0 1 2


Sample output:
UURDDLLUUURRDRDDDLLU

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int, input().split())

ans = []
for i in range(tx-sx):
    ans.append('R')
for i in range(ty-sy):
    ans.append('U')

for i in range(tx-sx):
    ans.append('L')
for i in range(ty-sy):
    ans.append('D')
    
ans.append('D')
ans.append('R')
for i in range(tx-sx):
    ans.append('R')
for i in range(ty-sy):
    ans.append('U')
ans.append('U')
ans.append('L')

ans.append('U')
ans.append('L')
for i in range(tx-sx):
    ans.append('L')
for i in range(ty-sy):
    ans.append('D')
ans.append('D')
ans.append('R')

print(''.join(ans))

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int,input().split())

x = tx - sx
y = ty - sy

ret = ''

#first
ret += 'U' * y
ret += 'R' * x
ret += 'D' * y
ret += 'L' * x

#second
ret += 'L'

ret += 'U' * (y + 1)
ret += 'R' * (x + 1)

ret += 'DR'

ret += 'D' * (y + 1)
ret += 'L' * (x + 1)

ret += 'U'

print(ret)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

x=tx-sx
y=ty-sy

route = 'U'*y+'R'*x+'D'*y+'L'*x
route += 'L'+'U'*(y+1)+'R'*(x+1)+'D' + 'R'+'D'*(y+1)+'L'*(x+1)+'U'
print(route)

Submission status: Accepted

Solution code:
X0,Y0,X1,Y1 = (int(x) for x in input().split())
s = ""
for i in range(Y1-Y0):
    s += "U"
for i in range (X1-X0):
    s += "R"
for i in range(Y1-Y0):
    s += "D"
for i in range(X1-X0+1):
    s += "L"
for i in range(Y1-Y0+1):
     s += "U"
for i in range (X1-X0+1):
    s += "R"
s += "DR"
for i in range(Y1-Y0+1):
    s += "D"
for i in range(X1-X0+1):
    s += "L"
s += "U"
print(s)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

dx, dy = tx - sx, ty - sy
print('U' * dy + 'R' * dx + 'D' * dy + 'L' * (dx + 1) + 'U' * (dy + 1) +
      'R' * (dx + 1) + 'DR' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U')

Submission status: Accepted

Solution code:
#51c
sx,sy,tx,ty = map(int, input().split())

#最初は二点を頂点とする四角の上を通り、二周目はその1つ外を通るルートにする
diff_x = abs(tx - sx) #四角の横
diff_y = abs(ty - sy) #四角の縦

ans = ["R" for _ in range(diff_x)]
ans += ["U" for _ in range(diff_y)]
ans += ["L" for _ in range(diff_x)]
ans += ["D" for _ in range(diff_y)]
ans += ["D"] #ここから2周目。1つ外側へ
ans += ["R" for _ in range(diff_x)]
ans += ["R"] #1つ外側へ
ans += ["U"] #1周目と同じ高さに
ans += ["U" for _ in range(diff_y)]
ans += ["L"] #これでtに到達
ans += ["U"] #1つ外側へ
ans += ["L" for _ in range(diff_x)]
ans += ["L"] #1つ外側へ
ans += ["D"] #1周目と同じ高さに
ans += ["D" for _ in range(diff_y)]
ans += ["R"] #これでゴール

print(str(''.join(ans)))

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())

ans='U'*(ty-sy)+'R'*(tx-sx)+'D'*(ty-sy)+'L'*(tx-sx)
ans+='L'+'U'*(ty-sy+1)+'R'*(tx-sx+1)+'D'
ans+='R'+'D'*(ty-sy+1)+'L'*(tx-sx+1)+'U'

print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

def go(start, goal):
    x = goal[0] - start[0]
    y = goal[1] - start[1]
    if x < 0:
        st = "L" * abs(x)
    else:
        st = "R" * x

    if y < 0:
        st += "D" * abs(y)
    else:
        st += "U" * y

    return st

def go2(start, goal):
    x = goal[0] - start[0]
    y = goal[1] - start[1]

    if y < 0:
        st = "D" * abs(y)
    else:
        st = "U" * y

    if x < 0:
        st += "L" * abs(x)
    else:
        st += "R" * x

    return st

ans = go([sx, sy], [tx, ty])
ans += go([tx, ty], [sx, sy])
ans += go([sx, sy], [sx - 1, sy])
ans += go2([sx - 1, sy], [tx, ty + 1])
ans += go2([tx, ty + 1], [tx, ty])
ans += go2([tx, ty], [tx + 1, ty])
ans += go2([tx + 1, ty], [sx, sy - 1])
ans += go2([sx, sy - 1], [sx, sy])
print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx - sx, ty - sy

print('U'*dy + 'R'*dx + 'D'*dy + 'L'*dx + 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D' + 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U')

Submission status: Accepted

Solution code:
s,t,x,y=map(int,input().split());x-=s;y-=t;r='R'*x+'U'*-~y+'L'*-~x+'D'*y;print(r+'DRDR'+r)

Submission status: Accepted

Solution code:
s,t,x,y=map(int,input().split());x-=s;y-=t;print('R'*x+'U'*y+'L'*x+'D'*-~y+'R'*-~x+'U'*
-~y+'LU'+'L'*-~x+'D'*-~y+'R')

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
x,y=tx-sx,ty-sy
print('R'*x+'U'*y+'L'*x+'D'*-~y+'R'*-~x+'U'*
-~y+'LU'+'L'*-~x+'D'*-~y+'R')

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
print("L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"*(ty-sy+1)+"L"*(tx-sx)+"D"+"R"*(tx-sx+1)+"U"*(ty-sy+1)+"L"*(tx-sx+1)+"D"*(ty-sy))

Submission status: Accepted

Solution code:
x1,y1,x2,y2 = (map(int,input().split()))
ans = ("R" * (x2 - x1)) + ("U" * (y2 - y1)) + ("L" * (x2 - x1)) + ("D" * (y2 - y1))  \
      + "D" + ("R" * (x2 - x1 + 1)) + ("U" * (y2 - y1 + 1)) + "L" + "U" \
      + ("L" * (x2 - x1 + 1)) + ("D" * (y2 - y1 + 1)) + "R"
print(ans)

Submission status: Accepted

Solution code:
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    sx, sy, tx, ty = il()

    ret = ''
    for n in range(ty - sy): ret += 'U'
    for n in range(tx - sx): ret += 'R'
    for n in range(ty - sy): ret += 'D'
    for n in range(tx - sx): ret += 'L'

    ret += 'L'
    for n in range(ty - sy + 1): ret += 'U'
    for n in range(tx - sx + 1): ret += 'R'
    ret += 'D'
    ret += 'R'
    for n in range(ty - sy + 1): ret += 'D'
    for n in range(tx - sx + 1): ret += 'L'
    ret += 'U'

    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx - sx, ty - sy
print('U'*dy + 'R'*dx + 'D'*dy + 'L'*(dx+1) + 'U'*(dy+1) + 'R'*(dx+1) + 'D' + 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U')

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
print('U'*(ty-sy),end='')
print('R'*(tx-sx),end='')
print('D'*(ty-sy),end='')
print('L'*(tx-sx),end='')
print('L',end='')
print('U'*(ty-sy+1),end='')
print('R'*(tx-sx+1),end='')
print('D',end='')
print('R',end='')
print('D'*(ty-sy+1),end='')
print('L'*(tx-sx+1),end='')
print('U')

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int,input().split())
x_dif = tx-sx
y_dif = ty-sy

print("U"*y_dif + "R"*x_dif + \
      "D"*y_dif + "L"*x_dif + \
      "L" + "U"*(y_dif+1) + "R"*(x_dif+1) + "D"\
      "R" + "D"*(y_dif+1) + "L"*(x_dif+1) + "U")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# C - Back and Forth
# 定数の定義
UP = "U"
DOWN = "D"
RIGHT = "R"
LEFT = "L"

# 標準入力の取得
sx,sy,tx,ty = list(map(int, input().split()))

# 移動経路の算出
# 左周りに最短経路を求める
diff_x = tx - sx
diff_y = ty - sy

min_path = ""
# 行き（1回目）
for y in range(diff_y):
    min_path += UP
for x in range(diff_x):
    min_path += RIGHT

# 帰り（1回目）
for y in range(diff_y):
    min_path += DOWN
for x in range(diff_x):
    min_path += LEFT

# 行き（2回目）
min_path += LEFT
for y in range(diff_y+1):
    min_path += UP
for x in range(diff_x+1):
    min_path += RIGHT
min_path += DOWN

# 帰り（2回目）
min_path += RIGHT
for y in range(diff_y+1):
    min_path += DOWN
for x in range(diff_x+1):
    min_path += LEFT
min_path += UP

print(min_path)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
w = tx - sx 
h = ty - sy 
ans = ""
for _ in range(h):
  ans += "U"
for _ in range(w):
  ans += "R"
for _ in range(h):
  ans += "D"
for _ in range(w):
  ans += "L"

ans += "L"
for _ in range(h+1):
  ans += "U"
for _ in range(w+1):
  ans += "R"
ans += "D"
ans += "R"
for _ in range(h+1):
  ans += "D"
for _ in range(w+1):
  ans += "L"
ans += "U"
print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
ans = ''
ans += 'R'*x
ans += 'U'*y
ans += 'L'*x
ans += 'D'*y
ans += 'DR'
ans += 'R'*x
ans += 'U'*y
ans += 'UL'
ans += 'UL'
ans += 'L'*x
ans += 'D'*y
ans += 'DR'
print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

if sy == ty:
    #  +---+
    #  |   |
    # -s---t-
    #  |   |
    #  +---+
    # l = 4
    l = tx - sx
    print("U" + "R"*l + "D" + "L"*l + "D" + "R" *
          l + "U" + "RDDL" + "L" * l + "LUUR")
elif sx == tx:
    l = ty - sy
    print("L" + "U"*l + "R" + "D"*l + "R" + "U" *
          l + "L" + "URRD" + "D" * l + "DLLU")
else:
    lx = tx - sx
    ly = ty - sy
    print("R"*lx + "U"*ly + "L"*lx + "D"*ly + "DR" + "R" *
          lx + "U" * ly + "UL" + "UL" + "L"*lx + "D"*ly + "DR")

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx - sx, ty - sy
m1 = 'R' * dx + 'U' * dy
m2 = 'L' * dx + 'D' * dy
m3 = 'D' + 'R' * (dx + 1) + 'U' * (dy + 1) + 'L'
m4 = 'U' + 'L' * (dx + 1) + 'D' * (dy + 1) + 'R'
print(m1 + m2 + m3 + m4)

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split())
A=""
for i in range(c-a):
  A=A+"R"
for i in range(d-b):
  A=A+"U"
for i in range(c-a):
  A=A+"L"
for i in range(d-b+1):
  A=A+"D"
for i in range(c-a+1):
  A=A+"R"
for i in range(d-b+1):
  A=A+"U"
A=A+"LU"
for i in range(c-a+1):
  A=A+"L"
for i in range(d-b+1):
  A=A+"D"
A=A+"R"
print(A)

Submission status: Accepted

Solution code:
# case への対応がだるいなと思ったら
# 右上方向しかない件について
Z = list(map(int, input().split()))
S, T = Z[:2], Z[2:]
dx, dy = [abs(T[i] - S[i]) for i in range(2)]
# first
result = ""
result += "U"*dy
result += "R"*dx
result += "D"*dy
result += "L"*dx
result += "L"
result += "U"*(dy + 1)
result += "R"*(dx + 1)
result += "D"
result += "R"
result += "D"*(dy + 1)
result += "L"*(dx + 1)
result += "U"
print(result)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    sx,sy,tx,ty=MI()
    w=tx-sx
    h=ty-sy
    ans="D"
    ans+="R"*(w+1)
    ans+="U"*(h+1)
    ans+="L"
    ans+="D"*h
    ans+="L"*(w+1)
    ans+="U"*(h+1)
    ans+="R"*(w+1)
    ans+="D"
    ans+="L"*w
    ans+="D"*h
    print(ans)

main()

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
ans='R'*(tx-sx)+'U'*(ty-sy)+'L'*(tx-sx)+'D'*(ty-sy+1)+'R'*(tx-sx+1)+'U'*(ty-sy+1)+'L'+'U'+'L'*(tx-sx+1)+'D'*(ty-sy+1)+'R'
print(ans)

Submission status: Accepted

Solution code:
S=list(map(int,input().split()))

sx=S[0]
sy=S[1]
tx=S[2]
ty=S[3]
answer=[]
for i in range(ty-sy):
    answer.append("U")
for i in range(tx-sx):
    answer.append("R")
for i in range(ty-sy):
    answer.append("D")
for i in range(tx-sx):
    answer.append("L")
answer.append("L")
for i in range(ty-sy+1):
    answer.append("U")
for i in range(tx-sx+1):
    answer.append("R")
answer.append("D")
answer.append("R")
for i in range(ty-sy+1):
    answer.append("D")
for i in range(tx-sx+1):
    answer.append("L")
answer.append("U")
for s in answer:
    print(s,end="")

Submission status: Accepted

Solution code:
a, b, c, d = map(int,input().split())

x = c - a
y = d - b

z = []
z += y * 'U'
z += x * 'R'
z += y * 'D'
z += (x + 1) * 'L'
z += (y + 1) * 'U'
z += (1 + x) * 'R'
z += 'D'
z += 'R'
z += (y + 1) * 'D'
z += (1 + x) *'L'
z += 'U'

print(''.join(z))

Submission status: Accepted

Solution code:
def sign(x):
    if x > 0:
        return 1
    if x == 0:
        return 0
    
    return -1

def solve():
    move_x = ["", "R", "L"]
    move_y = ["", "U", "D"]
    
    sx, sy, tx, ty = list(map(int, input().split()))
    
    dx = tx - sx
    dy = ty - sy

    outward = ""
    homeward = ""
    
    outward = move_x[sign(dx)] * abs(dx) + move_y[sign(dy)] * abs(dy)
    homeward = move_x[-sign(dx)] * abs(dx) + move_y[-sign(dy)] * abs(dy)
    
    fir_route = outward + homeward
    sec_route = move_y[-sign(dy)] + move_x[sign(dx)] + outward + move_y[sign(dy)] + move_x[-sign(dx)] + move_y[sign(dy)] + move_x[-sign(dx)] + homeward + move_y[-sign(dy)] + move_x[sign(dx)]

    print(fir_route, end="")
    print(sec_route)

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
#Back and Forth
#四角形を描くようにして移動する
#次に，四角形より最初と最後1つずらした形を構成する．

def sign(x):
    if x > 0:
        return 1
    if x == 0:
        return 0
    
    return -1

def solve():
    move_x = ["", "R", "L"]
    move_y = ["", "U", "D"]
    
    sx, sy, tx, ty = list(map(int, input().split()))
    
    dx = tx - sx
    dy = ty - sy

    outward = ""
    homeward = ""


    if dx == 0 and dy == 0:
        print()
        return
    
    if dx == 0:
        outward = move_y[sign(dy)] * abs(dy)
        homeward = move_y[-sign(dy)] * abs(dy)

        fir_route = outward + "R" + homeward + "L"
        sec_route = "L" + outward + "R" + move_y[sign(dy)] + "RR" + move_y[-sign(dy)] + homeward + move_y[-sign(dy)] + "LL" + move_y[sign(dy)]

        print(fir_route, end="")
        print(sec_route)

        return

    if dy == 0:
        outward = move_x[sign(dx)] * abs(dx)
        homeward = move_x[-sign(dx)] * abs(dx)

        fir_route = outward + "U" + homeward + "D"
        sec_route = "D" + outward + "U" + move_x[sign(dx)] + "UU" + move_x[-sign(dx)] + homeward + move_x[-sign(dx)] + "DD" + move_x[sign(dx)]

        print(fir_route, end="")
        print(sec_route)

        return
    
    outward = move_x[sign(dx)] * abs(dx) + move_y[sign(dy)] * abs(dy)
    homeward = move_x[-sign(dx)] * abs(dx) + move_y[-sign(dy)] * abs(dy)
    
    fir_route = outward + homeward
    sec_route = move_y[-sign(dy)] + move_x[sign(dx)] + outward + move_y[sign(dy)] + move_x[-sign(dx)] + move_y[sign(dy)] + move_x[-sign(dx)] + homeward + move_y[-sign(dy)] + move_x[sign(dx)]

    print(fir_route, end="")
    print(sec_route)

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())

dx=tx-sx
dy=ty-sy

ans =      "U"*dy +          "R"*dx+"D"*dy+"L"*dx
ans+="L" + "U"*dy + "U"+"R"+"R"*dx+"D"
ans+="R"+"D"*dy+"D"+"L"+"L"*dx+"U"

print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
h, w = (ty-sy), (tx-sx)
inner_route = "U"*h+"R"*w+"D"*h+"L"*w
outer_route = "L"+"U"*(h+1)+"R"*(w+1)+"D"
outer_route += "R"+"D"*(h+1)+"L"*(w+1)+"U"
print(inner_route+outer_route)

Submission status: Accepted

Solution code:

sx,sy,tx,ty = map(int,input().split())
y = abs(ty-sy)
x = abs(tx-sx)
ans = ""

for i in range(y):
    ans += "U"
for i in range(x):
    ans += "R"
for i in range(y):
    ans += "D"
for i in range(x+1):
    ans += "L"
for i in range(y+1):
    ans += "U"
for i in range(x+1):
    ans += "R"
ans += "DR"
for i in range(y+1):
    ans += "D"
for i in range(x+1):
    ans += "L"
ans += "U"

print(ans)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

sx, sy, tx, ty = list(map(int, input().split(' ')))

dfx = tx - sx
dfy = ty - sy

routes = ''

routes += 'U' * dfy
routes += 'R' * dfx
routes += 'D' * dfy
routes += 'L' * dfx

routes += 'L'
routes += 'U' * (dfy + 1)
routes += 'R' * (dfx + 1)
routes += 'D'

routes += 'R'
routes += 'D' * (dfy + 1)
routes += 'L' * (dfx + 1)
routes += 'U'

print(routes)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

x = tx - sx
y = ty - sy

ans = ''

# 行き1回目
for i in range(x):
    ans += 'R'
for i in range(y):
    ans += 'U'
# 帰り1回目
for i in range(x):
    ans += 'L'
for i in range(y):
    ans += 'D'
# 行き2回目
ans += 'D'
for i in range(x + 1):
    ans += 'R'
for i in range(y + 1):
    ans += 'U'
ans += 'L'
# 帰り2回目
ans += 'U'
for i in range(x + 1):
    ans += 'L'
for i in range(y + 1):
    ans += 'D'
ans += 'R'

print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int,input().split())
height = ty - sy
width = tx - sx 
# path1
path1 = ['U' for _ in range(height) ]
path1.extend([ 'R' for _ in range(width)])
# path2
path2 = ['D' for _ in range(height)]
path2.extend([ 'L' for _ in range(width)])
# path3
path3 = ['U' for _ in range(height+1)]
path3.extend([ 'R' for _ in range(width+1)])
path3.insert(0,'L')
path3.extend(['D'])
# path4
path4 = ['D' for _ in range(height+1)]
path4.extend([ 'L' for _ in range(width+1) ])
path4.insert(0,'R')
path4.extend(['U'])

path = path1
path.extend(path2)
path.extend(path3)
path.extend(path4)

print(''.join(path))

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int,input().split())

x1 = tx-sx
y1 = ty-sy
print("U"*y1+"R"*x1+"D"*y1+"L"*x1+"L"+"U"*(1+y1)+"R"*(1+x1)+"D"+"R"+"D"*(1+y1)+"L"*(1+x1)+"U")

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
dx = tx-sx
dy = ty-sy
ans = 'U'*dy + 'R'*dx + 'D'*dy + 'L'*dx
ans += 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D'
ans += 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'
print(ans)

Submission status: Accepted

Solution code:
a, b, c, d = map(int, input().split())
ans = ''
ans += 'R' * (c - a) + 'U' * (d - b)
ans += 'L' * (c - a) + 'D' * (d - b)
ans += 'D' + 'R' * (c - a + 1) + 'U' * (d - b + 1) + 'L'
ans += 'U' + 'L' * (c - a + 1) + 'D' * (d - b + 1) + 'R'
print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
print(
    "U" * (ty - sy)
    + "R" * (tx - sx)
    + "D" * (ty - sy)
    + "L" * (tx - sx)
    + "L"
    + "U" * (ty - sy + 1)
    + "R" * (tx - sx + 1)
    + "DR"
    + "D" * (ty - sy + 1)
    + "L" * (tx - sx + 1)
    + "U"
)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    sx,sy,tx,ty=MI()
    ans=[]
    
    for i in range(ty-sy):
        ans.append("U")
    for i in range(tx-sx+1):
        ans.append("R")
    for i in range(ty-sy+1):
        ans.append("D")
    for i in range(tx-sx+1):
        ans.append("L")
    ans.append("U")
    ans.append("L")
    for i in range(ty-sy+1):
        ans.append("U")
    for i in range(tx-sx+1):
        ans.append("R")
    for i in range(ty-sy+1):
        ans.append("D")
    for i in range(tx-sx):
        ans.append("L")
        
    print(''.join(map(str, ans)))
    

main()

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx-sx, ty-sy
ans = 'U'*dy + 'R'*dx + 'D'*dy + 'L'*dx
ans += 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D'
ans += 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'
print(ans)

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())

ans="U"*(ty-sy)+"R"*(tx-sx)+"D"*(ty-sy)+"L"*(tx-sx)+"L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"+"R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U"
print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

u = 'U'
d = 'D'
r = 'R'
l = 'L'
x = tx - sx
y = ty - sy
result = []
# 1回目の行き
result += [u]*y
result += [r]*x
# 1回目の帰り
result += [d]*y
result += [l]*x

# 2回目の行き
result += [d]
result += [r]*(x+1)
result += [u]*(y+1)
result += [l]
# 2回目の帰り
result += [u]
result += [l]*(x+1)
result += [d]*(y+1)
result += [r]

print(''.join(result))

Submission status: Accepted

Solution code:
def resolve():
    s_x, s_y, t_x, t_y = map(int, input().split())

    d_x = t_x - s_x
    d_y = t_y - s_y
    p_1 = 'U'*d_y + 'R'*d_x
    p_2 = 'D'*d_y + 'L'*d_x
    p_3 = 'L' + 'U' * (d_y+1) + 'R' * (d_x+1) + 'D'
    p_4 = 'R' + 'D' * (d_y+1) + 'L' * (d_x + 1) + 'U'

    print(p_1+p_2+p_3+p_4)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

dx, dy = tx-sx, ty - sy

ans = ""
ans += "U" * dy
ans += "R" * dx
ans += "D" * dy
ans += "L" * dx

ans += "L"
ans += "U" * (dy+1)
ans += "R" * (dx+1)
ans += "DR"
ans += "D" * (dy+1)
ans += "L" * (dx+1)
ans += "U"

print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

ans = (abs(tx - sx)  * 'R') + (abs(ty - sy) * 'U')
ans += ((abs(tx - sx) * 'L') + (abs(ty - sy) * 'D'))
ans += 'L' + ((abs(ty - sy) + 1) * 'U') + ((abs(tx - sx) + 1) * 'R') + 'D'
ans += 'R' + ((abs(ty - sy) + 1) * 'D') + ((abs(tx - sx) + 1) * 'L') + 'U'
print(ans)

Submission status: Accepted

Solution code:
[sx,sy,tx,ty] = [int(i) for i in input().split()]
"""
cnt = 0

while cnt < 4:
    #s -> t
    if cnt % 2 == 0:
"""
#出入り*2で周りの点を4回通ることになる
#(sx-1,sy),(sx+1,sy),(sx,sy-1),(sx,sy+1)
#長方形の端を行って帰ってきたあと、それの1周り遠くを進む道

dx = tx-sx
dy = ty-sy
ans = ""
#1周目
ans += "R" * dx + "U" * dy+"L" * dx + "D" * dy
#2週目行き
ans += "D" + "R" *(dx+1) + "U" * (dy+1) +"L"
#2週目帰り
ans += "U" + "L" * (dx+1) + "D" * (dy+1) +"R"

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

sx,sy,tx,ty = list(map(int, input().rstrip().split()))
#-----

h = ty-sy
w = tx-sx

st1 = "U"*h + "R"*w
ts1 = "D"*h + "L"*w

st2 = "L" + "U"*(h+1) + "R"*(w+1) + "D"
ts2 = "R" + "D"*(h+1) + "L"*(w+1) + "U"

ans = st1 + ts1 + st2 + ts2
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
a,b,c,d = map(int,input().split())
print("R"*(c-a)+"U"*(d-b)+"L"*(c-a)+"D"*(d-b+1)+\
    "R"*(c-a+1)+"U"*(d-b+1)+"L"+"U"+"L"*(c-a+1)+"D"*(d-b+1)+"R")

Submission status: Accepted

Solution code:
# Set given variables
inputVec = input().split(' ')
s_x = int(inputVec[0])
s_y = int(inputVec[1])
t_x = int(inputVec[2])
t_y = int(inputVec[3])

# Calculate difference
d_x = t_x - s_x
d_y = t_y - s_y

# move 1
result = 'R' * d_x + 'U' * d_y

# move 2
result += 'L' * d_x + 'D' * d_y

# move 3
result += 'D' + 'R' * (d_x + 1) + 'U' * (d_y + 1) + 'L'

# move 4
result += 'U' + 'L' * (d_x + 1) + 'D' * (d_y + 1) + 'R'

print(result)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
s = ""
dx, dy = abs(tx - sx), abs(ty - sy)
dxy = dx + dy
for a in range(dx):
  s += "R"
for b in range(dy):
  s += "U"
for c in range(dx):
  s += "L"
for d in range(dy):
  s += "D"
s += "D"
for e in range(dx + 1):
  s += "R"
for f in range(dy + 1):
  s += "U"
s += "L"
s += "U"
for g in range(dx + 1):
  s += "L"
for h in range(dy + 1):
  s += "D"
s += "R"
print(s)

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int, input().split())

ans = []
for i in range(sy, ty):
    ans.append('U')
for i in range(sx, tx):
    ans.append('R')
for i in range(ty, sy, -1):
    ans.append('D')
for i in range(tx, sx-1, -1):
    ans.append('L')
for i in range(sy, ty+1):
    ans.append('U')
for i in range(sx-1, tx):
    ans.append('R')
for i in range(ty+1, ty, -1):
    ans.append('D')
for i in range(tx, tx+1):
    ans.append('R')
for i in range(ty, sy-1, -1):
    ans.append('D')
for i in range(tx+1, sx, -1):
    ans.append('L')
for i in range(sy-1, sy):
    ans.append('U')
print(''.join(ans))

Submission status: Accepted

Solution code:
route=''
sx,sy,tx,ty=map(int,input().split())
h=abs(ty-sy)
w=abs(tx-sx)
for i in range(h):
    route+=str("U")
for j in range(w):
    route+=str("R")
for i in range(h):
    route+=str("D")
for i in range(w+1):
    route+=str("L")
for i in range(h+1):
    route+=str("U")
for i in range(w+1):
    route+=str("R")
route+=str("D")
route+=str('R')
for i in range(h+1):
    route+=str("D")
for i in range((w+1)):
    route+=str("L")
route+=str("U")
print(route)

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
print("R"*(tx-sx)+"U"*(ty-sy)+"L"*(tx-sx)+"D"*(ty-sy)+
      "D"+"R"*(tx-sx+1)+"U"*(ty-sy+1)+"L"+
      "U"+"L"*(tx-sx+1)+"D"*(ty-sy+1)+"R")

Submission status: Accepted

Solution code:
sx , sy , tx , ty = map(int,input().split())
a = []

for _ in range(tx - sx):
    a.append("R")
for _ in range(ty - sy):
    a.append("U")
for _ in range(tx - sx):
    a.append("L")
for _ in range(ty - sy):
    a.append("D")
    
a.append("D")

for _ in range(tx - sx + 1):
    a.append("R")
for _ in range(ty - sy + 1):
    a.append("U")
    
a.append("L")
a.append("U")

for _ in range(tx - sx + 1):
    a.append("L")
for _ in range(ty - sy + 1):
    a.append("D")
    
a.append("R")

print("".join(a))

Submission status: Accepted

Solution code:
a,b,c,d = map(int,input().split())
for _ in range(d-b):
  print('U', end='')
for _ in range(c-a):
  print('R', end='')
print('U', end='')
for _ in range(c-a+1):
  print('L', end='')
for _ in range(d-b+1):
  print('D', end='')
print('R', end='')  
for _ in range(c-a):
  print('R', end='')
for _ in range(d-b):
  print('U', end='')
print('R', end='')
for _ in range(d-b+1):
  print('D', end='')
for _ in range(c-a+1):
  print('L', end='')
print('U')

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int, input().split())
ans = []
for _ in range(ty-sy):
  ans.append("U")
for i in range(tx-sx):
    ans.append("R")
for i in range(abs(sy-ty)):
    ans.append("D")
for i in range(abs(sx-tx)):
    ans.append("L")

ans.append("L")
for i in range(ty-sy+1):
    ans.append("U")
for i in range(tx-sx+1):
    ans.append("R")
ans.append("D")
ans.append("R")
for i in range(abs(sy-ty)+1):
    ans.append("D")
for i in range(abs(sx-tx)+1):
    ans.append("L")
ans.append("U")

print("".join(ans))

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
route1, route2, route3, route4 = '', '', 'L', 'R'
dis_x = tx - sx
dis_y = ty - sy
route1 = 'U' * dis_y + 'R' * dis_x
route2 = 'D' * dis_y + 'L' * dis_x
route3 += 'U' * (dis_y+1) + 'R' * (dis_x+1) + 'D'
route4 += 'D' * (dis_y+1) + 'L' * (dis_x+1) + 'U'
print(route1 + route2 + route3 + route4)

Submission status: Accepted

Solution code:
#ABC051
sx,sy,tx,ty = list(map(int,input().split()))
x,y = [tx-sx,ty-sy]
s = "U"*y+"R"*x+"D"*y+"L"*x + "L"+"U"*(y+1)+"R"*(x+1)+"D"+"R"+"D"*(y+1)+"L"*(x+1)+"U"
print(s)

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int, input().split())
y = ty-sy
x = tx-sx
print('U'*y+'R'*x+'D'*y+'L'*x+'D'+'R'*(x+1)+'U'*(y+1)+'LU'+'L'*(x+1)+'D'*(y+1)+'R')

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy

ans = dx*'R'+dy*'U'+dx*'L'+dy*'D'+'L'+(dy+1)*'U'+(dx+1)*'R'+'D'+'R'+(dy+1)*'D'+(dx+1)*'L'+'U'
print(ans)

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
xd=tx-sx;yd=ty-sy
res='R'*xd+'U'*yd+'L'*xd+'D'*yd+'D'+'R'*(xd+1)+'U'*(yd+1)+'LU'+'L'*(xd+1)+'D'*(yd+1)+'R'
print(res)

Submission status: Accepted

Solution code:
# UU  R     DD  L
#LUUU RR DR DDD LLU

sx, sy, tx, ty = map(int, input().split())
print('U'*abs(ty-sy),
        'R'*abs(tx-sx),
        'D'*abs(ty-sy),
        'L'*abs(tx-sx),
        'L',
        'U'*(abs(ty-sy)+1),
        'R'*(abs(tx-sx)+1),
        'DR',
        'D'*(abs(ty-sy)+1),
        'L'*(abs(tx-sx)+1),
        'U',
        sep='')

Submission status: Accepted

Solution code:
x1, y1, x2, y2 = map(int, input().split())

ans = ''

dx = x2 - x1
dy = y2 - y1

ans += 'R'*dx + 'U'*dy + 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'*(dy+1) + 'R'*dx + 'U' + 'L'*(dx+1) + 'D'*(dy+1) + 'R'

print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

xlen = tx - sx
ylen = ty - sy

ans1 = "U" * (ylen) + "R" * (xlen)
ans2 = "D" * (ylen) + "L" * (xlen)
ans3 = "L" + "U" * (ylen+1) + "R" * (xlen+1) + "D"
ans4 = "R" + "D" * (ylen+1) + "L" * (xlen+1) + "U"

print(ans1 + ans2 + ans3 + ans4)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy

ans = ""
ans += "U" * dy
ans += "R" * dx
ans += "D" * dy
ans += "L" * (1 + dx)
ans += "U" * (1 + dy)
ans += "R" * (1 + dx)
ans += "DR"
ans += "D" * (1 + dy)
ans += "L" * (1 + dx)
ans += "U"
print(ans)

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
yoko=tx-sx
tate=ty-sy
print('U'*tate+'R'*yoko+'D'*tate+'L'*yoko+'L'+'U'*(tate+1)+'R'*(yoko+1)+'D'+'R'+'D'*(tate+1)+'L'*(yoko+1)+'U')

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
route=["","","",""]
route[0]='U'*dy+'R'*dx
route[1]='D'*dy+'L'*dx
route[2]='L'+'U'*(dy+1)+'R'*(dx+1)+'D'
route[3]='R'+'D'*(dy+1)+'L'*(dx+1)+'U'
print("".join(route))

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
st1='U'*dy+'R'*dx
ts1='D'*dy+'L'*dx
st2='L'+'U'*(dy+1)+'R'*(dx+1)+'D'
ts2='R'+'D'*(dy+1)+'L'*(dx+1)+'U'
print(st1+ts1+st2+ts2)

Submission status: Accepted

Solution code:
#051_C
sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
st1='U'*dy+'R'*dx
ts1='D'*dy+'L'*dx
st2='L'+'U'*(dy+1)+'R'*(dx+1)+'D'
ts2='R'+'D'*(dy+1)+'L'*(dx+1)+'U'
print(st1+ts1+st2+ts2)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
ans = ''
ans += 'R' * (tx - sx) + 'U' * (ty - sy)
ans += 'L' * (tx - sx) + 'D' * (ty - sy)
ans += 'D' + 'R' * (tx - sx + 1) + 'U' * (ty - sy + 1) + 'L'
ans += 'U' + 'L' * (tx - sx + 1) + 'D' * (ty - sy + 1) + 'R'
print(ans)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
import heapq

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

sx, sy, tx, ty = MAP()

W = tx - sx
H = ty - sy

# first_cicle
A = "U" * H + "R" * W + "D" * H + "L" * W
B = "L" + "U" * (H + 1) + "R" * (W + 1) + "D" \
    + "R" + "D" * (H + 1) + "L" * (W + 1) + "U"
print(A+B)