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:
def main():
    sx, sy, tx, ty = (int(i) for i in input().split())
    x, y = sx, sy
    goal_cnt = 0
    ans = ""
    finished = {(sx, sy)}
    while goal_cnt < 4:
        if goal_cnt % 2 == 0:
            if y < ty and (x, y+1) not in finished:
                y += 1
                ans = ans + "U"
            elif y > ty and (x, y-1) not in finished:
                y -= 1
                ans = ans + "D"
            elif x < tx and (x+1, y) not in finished:
                x += 1
                ans = ans + "R"
            elif x > tx and (x-1, y) not in finished:
                x -= 1
                ans = ans + "L"
            elif y == ty and (x, y+1) not in finished:
                y += 1
                ans = ans + "U"
            elif y == ty and (x, y-1) not in finished:
                y -= 1
                ans = ans + "D"
            elif x == tx and (x+1, y) not in finished:
                x += 1
                ans = ans + "R"
            elif x == tx and (x-1, y) not in finished:
                x -= 1
                ans = ans + "L"
            elif (x, y-1) not in finished:
                y -= 1
                ans = ans + "D"
            elif (x-1, y) not in finished:
                x -= 1
                ans = ans + "L"
            elif (x, y+1) not in finished:
                y += 1
                ans = ans + "U"
            elif (x+1, y) not in finished:
                x += 1
                ans = ans + "R"
            else:
                raise Exception("panic!")
            if x == tx and y == ty:
                goal_cnt += 1
                finished.discard((sx, sy))
                finished.add((tx, ty))
            else:
                finished.add((x, y))
        else:
            if y < sy and (x, y+1) not in finished:
                y += 1
                ans = ans + "U"
            elif y > sy and (x, y-1) not in finished:
                y -= 1
                ans = ans + "D"
            elif x < sx and (x+1, y) not in finished:
                x += 1
                ans = ans + "R"
            elif x > sx and (x-1, y) not in finished:
                x -= 1
                ans = ans + "L"
            elif y == sy and (x, y+1) not in finished:
                y += 1
                ans = ans + "U"
            elif y == sy and (x, y-1) not in finished:
                y -= 1
                ans = ans + "D"
            elif x == sx and (x+1, y) not in finished:
                x += 1
                ans = ans + "R"
            elif x == sx and (x-1, y) not in finished:
                x -= 1
                ans = ans + "L"
            elif (x, y-1) not in finished:
                y -= 1
                ans = ans + "D"
            elif (x-1, y) not in finished:
                x -= 1
                ans = ans + "L"
            elif (x, y+1) not in finished:
                y += 1
                ans = ans + "U"
            elif (x+1, y) not in finished:
                x += 1
                ans = ans + "R"
            else:
                raise Exception("panic!")
            if x == sx and y == sy:
                goal_cnt += 1
                finished.discard((tx, ty))
                finished.add((sx, sy))
            else:
                finished.add((x, y))
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=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())
dx=tx-sx
dy=ty-sy
Dx=abs(dx)
Dy=abs(dy)
val='U'*Dy+'R'*Dx+'D'*Dy+'L'*(Dx+1)+'U'*(Dy+1)+'R'*(Dx+1)+'D'+'R'+'D'*(Dy+1)+'L'*(Dx+1)+'U'
ans_l=[]
for _ in range(len(val)):
	ans_l.append(val[_])
l=len(ans_l)
if dy<0:
	for i in range(l):
		if ans_l[i]=='U':
			ans_l[i]='D'
		elif ans_l[i]=='D':
			ans_l[i]='U'
if dx<0:
	for j in range(l):
		if ans_l[j]=='R':
			ans_l[j]='L'
		elif ans_l[j]=='L':
			ans_l[j]='R'
print("".join(ans_l))

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy

result = ''
result += 'R' * dx + 'U' * dy  # 1st Forth
result += 'L' * dx + 'D' * dy  # 1st Back
result += 'D' + 'R' * (dx + 1) + 'U' * (dy + 1) + 'L'  # 2nd Forth
result += 'U' + 'L' * (dx + 1) + 'D' * (dy + 1) + 'R'  # 2nd Back
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx,sy,tx,ty = (int(x) for x in input().split())
root=''

for i in range(tx-sx):
    root+='R'
for j in range(ty-sy):
    root+='U'

for i in range(tx-sx):
    root+='L'
for j in range(ty-sy):
    root+='D'

root+='L'
for j in range(ty-sy+1):
    root+='U'
for i in range(tx-sx+1):
    root+='R'
root+='D'
root+='R'
for j in range(ty-sy+1):
    root+='D'
for i in range(tx-sx+1):
    root+='L'
root+='U'

print(root)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def func(x1, y1, x2, y2):
    xd = x2 - x1
    yd = y2 - y1
    for i in range(xd):
        print("R", end="")
    for j in range(yd):
        print("U", end="")
    return

def func2(a1, b1, a2, b2):
    ad = a2 - a1
    bd = b2 - b1
    for k in range(ad):
        print("L", end="")
    for l in range(bd):
        print("D", end="")
    
a = list(map(int,input().split()))

func(a[0],a[1],a[2],a[3])
func2(a[0],a[1],a[2],a[3])
print("D", end="")
func(a[0],(a[1] - 1),(a[2] + 1),a[3])
print("L", end="")
print("U", end="")
func2(a[0],(a[1] - 1),(a[2] + 1),a[3])
print("R", end="")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
ans=""
width=tx-sx
length=ty-sy
A,B,C,D="U"*length,"R"*width,"D"*length,"L"*width
for i in range(2):
    if i==0:ans +=A+B+C+D
    else:ans +="L"+A+"UR"+B+"DR"+C+"DL"+D+"U"
print(ans)

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
ans=""
width=tx-sx
length=ty-sy
A="U"*length
B="R"*width
C="D"*length
D="L"*width
for i in range(2):
    if i==0:
        ans +=A+B+C+D
    else:
        ans +="L"+A+"UR"+B+"DR"+C+"DL"+D+"U"
print(ans)

Submission status: Accepted

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

# スペース区切りの整数の入力
sx, sy, tx, ty = map(int, input().split())

S = ""

xlen = tx - sx
ylen = ty - sy

#1
for i in range(xlen):
  S += "R"
for i in range(ylen):
  S += "U"
  
#2
for i in range(xlen):
  S += "L"
for i in range(ylen):
  S += "D"

#3
S += "D"
for i in range(xlen + 1):
  S += "R"
for i in range(ylen + 1):
  S += "U"
S += "L"

#4
S += "U"
for i in range(xlen + 1):
  S += "L"
for i in range(ylen + 1):
  S += "D"
S += "R"

print(S)

Submission status: Accepted

Solution code:
# ABC051 C - Back and Forth

sx, sy, tx, ty = map(int, input().split())
for i in range(2):
    if i > 0:
        [print("L", end="") for j in range(i)]
    [print("U", end="") for y in range(ty - sy + i)]
    [print("R", end="") for x in range(tx - sx + i)]
    if i > 0:
        [print("D", end="") for j in range(i)]
        [print("R", end="") for j in range(i)]
    [print("D", end="") for y in range(ty - sy + i)]
    [print("L", end="") for x in range(tx - sx + i)]
    if i > 0:
        [print("U", end="") for j in range(i)]
print()

Submission status: Accepted

Solution code:
#Back and Forth
sx, sy, tx, ty = map(int, input().split())
R = ""
for i in range (tx-sx):
    R = R + "R"
for i in range (ty-sy):
    R = R + "U"
for i in range (tx-sx):
    R = R + "L"
for i in range (ty-sy):
    R = R + "D"
R = R + "D"
for i in range (tx-sx+1):
    R = R + "R"
for i in range (ty-sy+1):
    R = R + "U"
R = R + "LU"
for i in range (tx-sx+1):
    R = R + "L"
for i in range (ty-sy+1):
    R = R + "D"
R = R + "R"
print(R)

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy

out = ""
for i in range(dy):
  out += "U"
for i in range(dx):
  out += "R"
for i in range(dy):
  out += "D"
for i in range(dx+1):
  out += "L"
for i in range(dy+1):
  out += "U"
for i in range(dx+1):
  out += "R"

out += "DR"

for i in range(dy+1):
  out += "D"
for i in range(dx+1):
  out += "L"

out += "U"

print(out)

Submission status: Accepted

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

dist_x = tx - sx
dist_y = ty - sy

print('R' * dist_x, end='')
print('U' * dist_y, end='')

print('L' * dist_x, end='')
print('D' * dist_y, end='')

print('D', end='')
print('R' * (dist_x + 1), end='')
print('U' * (dist_y + 1), end='')
print('L', end='')

print('U', end='')
print('L' * (dist_x + 1), end='')
print('D' * (dist_y + 1), end='')
print('R', end='')

Submission status: Accepted

Solution code:
#rip this is hard 

def read_input():
  l = [int(item) for item in input().split()]
  sx = l[0]
  sy = l[1]
  tx = l[2]
  ty = l[3]
  return sx,sy,tx,ty

def main():
  sx,sy,tx,ty = read_input()
  dx = tx - sx
  dy = ty - sy
  s = ''
  s+='U'*dy+'R'*dx
  s+='D'*dy+'L'*dx
  s+='L'+'U'*(dy+1)+'R'*(dx+1)+'D'
  s+='R'+'D'*(dy+1)+'L'*(dx+1)+'U'
  print(s)

  

if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# ABC051 C - Back and Forth
"""
0 0 1 2
UURDDLLUUURRDRDDDLLU
"""

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

# YU1
[print("U", end="") for y in range(ty - sy)]

# XR1
[print("R", end="") for x in range(tx - sx)]

# YD1
[print("D", end="") for y in range(ty - sy)]

# XL1
[print("L", end="") for x in range(tx - sx)]

# XL2
print("L", end="")

# YU2
[print("U", end="") for y in range(ty - sy + 1)]

# XR2
[print("R", end="") for x in range(tx - sx + 1)]

# YD2
print("D", end="")

# XR2
print("R", end="")

# YD3
[print("D", end="") for y in range(ty - sy + 1)]

# XL3
[print("L", end="") for x in range(tx - sx + 1)]

# YU3
print("U", end="")

print()

Submission status: Accepted

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

Submission status: Accepted

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

dx = abs(tx - sx)
dy = abs(ty - sy)

move_x = "R" * dx
move_y = "U" * dy

f_move = move_y + move_x

if "R" in f_move:
  s_move = f_move.replace("R","L")
if "U" in s_move:
  s_move = s_move.replace("U","D")

t_move = "L" + "U" + f_move + "R" + "D"

ff_move = "R" + "D" + s_move + "L" + "U"

total = f_move + s_move + t_move + ff_move  
  
print(total)

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)+"D"+"R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U")

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)+'D'+'R'*(tx-sx+1)+'U'*(ty-sy+1)+'L'+'U'+(tx-sx+1)*'L'+'D'*(ty-sy+1)+'R']
print(*ans)

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy

r = ''
for i in range(dy):
  r += 'U'

for i in range(dx):
  r += 'R'
  
for i in range(dy):
  r += 'D'

for i in range(dx):
  r += 'L'

r += 'L'
for i in range(dy + 1):
  r += 'U'
for i in range(dx + 1):
  r += 'R'
r += 'D'
r += 'R'
for i in range(dy + 1):
  r += 'D'
for i in range(dx + 1):
  r += 'L'
r += 'U'

print(r)

Submission status: Accepted

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

Submission status: Accepted

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

dx = tx-sx
dy = ty-sy

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

print(a+b)

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
s_1 = ''
if (int(A[0]) < 0) and (int(A[2]) < 0):
  a = abs(int(A[0])) - abs(int(A[2]))
elif (int(A[0]) < 0) and (int(A[2]) > 0):
  a = abs(int(A[0])) + abs(int(A[2]))
else:
  a = int(A[2]) -  int(A[0])
  
if (int(A[1]) < 0) and (int(A[3]) < 0):
  b = abs(int(A[1])) - abs(int(A[3]))
elif (int(A[1]) < 0) and (int(A[3]) > 0):
  b = abs(int(A[1])) + abs(int(A[3]))
else:
  b = int(A[3]) -  int(A[1])

for i in range(b):
  s_1 = s_1 + 'U'
for i in range(a):
  s_1 = s_1 + 'R'
  
for i in range(b):
  s_1 = s_1 + 'D'
for i in range(a):
  s_1 = s_1 + 'L'
  
s_1 = s_1 + 'L'
for i in range(b+1):
  s_1 = s_1 + 'U'
for i in range(a+1):
  s_1 = s_1 + 'R'
s_1 = s_1 + 'D'
  
s_1 = s_1 + 'R'
for i in range(b+1):
  s_1 = s_1 + 'D'
for i in range(a+1):
  s_1 = s_1 + 'L'
s_1 = s_1 + 'U'
print(s_1)

Submission status: Accepted

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


main()

Submission status: Accepted

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


main()

Submission status: Accepted

Solution code:
def f(d1, t1, d2, t2):
    print(d1 * t1, end="")
    print(d2 * t2, end="")


def main():
    U, D, L, R = "U", "D", "L", "R"
    sx, sy, tx, ty = map(int, input().split())
    f(R, tx - sx, U, ty - sy)
    f(L, tx - sx, D, ty - sy)
    f(D, 1, "", 0)
    f(R, tx + 1 - sx, U, ty + 1 - sy)
    f(L, 1, "", 0)
    f(U, 1, "", 0)
    f(L, tx + 1 - sx, D, ty + 1 - sy)
    f(R, 1, "", 0)
    print()
    return


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, d = map(int, input().split())
S = []
e = c - a
f = d - b
for i in range(f):
    S.append("U")
for i in range(e+1):
    S.append("R")
for i in range(f+1):
    S.append("D")
for i in range(e+1):
    S.append("L")
S.append("U")
S.append("L")
for i in range(f+1):
    S.append("U")
for i in range(e+1):
    S.append("R")
for i in range(f+1):
    S.append("D")
for i in range(e):
    S.append("L")
ans = "".join(S)
print(ans)

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+1)+'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())
a1 = "U"*(ty-sy) + "R"*(tx-sx)
a2 = "D"*(ty-sy) + "L"*(tx-sx)
a3 = "D"+"R"*(tx-sx+1)+"U"*(ty-sy+1)+"L"
a4 = "U"+"L"*(tx-sx+1)+"D"*(ty-sy+1)+"R"
print(a1+a2+a3+a4)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = [int(coodinate) for coodinate in input().split()]
dx = tx - sx
dy = ty - sy

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

print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = [int(coodinate) for coodinate in input().split()]
d_x = tx - sx
d_y = ty - sy

route = []
route.append('U' * d_y + 'R' * d_x)
route.append('D' * d_y + 'L' * d_x)
route.append('L' + 'U' * (d_y + 1) +
    'R' * (d_x + 1) + 'D')
route.append('R' + 'D' * (d_y + 1) + 'L' * (d_x + 1)
    + 'U')

ans = ''.join(route)
print(ans)

Submission status: Accepted

Solution code:
import sys


def solve(sx: int, sy: int, tx: int, ty: int):
    print("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")
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    sx = int(next(tokens))  # type: int
    sy = int(next(tokens))  # type: int
    tx = int(next(tokens))  # type: int
    ty = int(next(tokens))  # type: int
    solve(sx, sy, tx, ty)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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) \
    + ["D"]\
    + ["R"] * (tx-sx+1)\
    + ["U"] * (ty-sy+1)\
    + ["L", "U"]\
    + ["L"] * (tx-sx+1)\
    + ["D"] * (ty-sy+1)\
    + ["R"]

print("".join(ans))

Submission status: Accepted

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

dx = (tx-sx)
dy = (ty-sy)

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

print(first+second)

Submission status: Accepted

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

if x>=0 and y>=0:
  ans=["U"]*y+["R"]*x+["D"]*y+["L"]*x+\
  	  ["L"]+["U"]*(y+1)+["R"]*(x+1)+["D"]+\
      ["R"]+["D"]*(y+1)+["L"]*(x+1)+["U"]
elif x>=0 and y<0:
  y=abs(y)
  ans=["D"]*y+["R"]*x+["U"]*y+["L"]*x+\
  	  ["L"]+["D"]*(y+1)+["R"]*(x+1)+["U"]+\
      ["R"]+["U"]*(y+1)+["L"]*(x+1)+["D"]
elif x<0 and y>=0:
  x=abs(x)
  ans=["U"]*y+["L"]*x+["D"]*y+["R"]*x+\
  	  ["R"]+["U"]*(y+1)+["L"]*(x+1)+["D"]+\
      ["L"]+["D"]*(y+1)+["R"]*(x+1)+["U"]
elif x<0 and y<0:
  x,y=abs(x),abs(y)
  ans=["D"]*y+["L"]*x+["U"]*y+["R"]*x+\
  	  ["R"]+["D"]*(y+1)+["L"]*(x+1)+["U"]+\
      ["L"]+["U"]*(y+1)+["R"]*(x+1)+["D"]
      
      
print("".join(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
sx,sy,tx,ty=map(int,input().split())

if sx!=tx and sy!=ty:
    r1="R"*(tx-sx)+"U"*(ty-sy)+"L"*(sx-tx)+"D"*(sy-ty)
    r2="L"*(tx-sx)+"D"*(ty-sy)+"R"*(sx-tx)+"U"*(sy-ty)
    r3=("D" if (ty-sy)>0 else "U")+"R"*(tx-sx+1)+"U"*(ty-sy+1)+"L"*(sx-tx+1)+"D"*(sy-ty+1)+("L" if (tx-sx)>0 else "R")
    r4=("U" if (ty-sy)>0 else "D")+"L"*(tx-sx+1)+"D"*(ty-sy+1)+"R"*(sx-tx+1)+"U"*(sy-ty+1)+("R" if (tx-sx)>0 else "D")

elif sx==tx:
    r1="R"+"U"*(ty-sy)+"D"*(sy-ty)+"L"
    r2="L"+"D"*(ty-sy)+"U"*(sy-ty)+"R"
    r3="U"*(ty-sy)+"D"*(sy-ty)
    r4=("U" if (ty-sy)>0 else "D")+"R"*2+("D"*(ty-sy+2) if (ty-sy)>0 else "U"*(sy-ty+2))+"L"*2+("U" if (ty-sy)>0 else "U")

elif sy==ty:
    r1="D"+"R"*(tx-sx)+"L"*(sx-tx)+"U"
    r2="U"+"L"*(tx-sx)+"R"*(sx-tx)+"D"
    r3="R"*(tx-sx)+"L"*(sx-tx)
    r4=("R" if (tx-sx)>0 else "L")+"D"*2+("L"*(tx-sx+2) if (tx-sx)>0 else "R"*(sx-tx+2))+"U"*2+("R" if (tx-sx)>0 else "L")

print(r1+r2+r3+r4)

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:
sx, sy, tx, ty = map(int, input().split())

x = tx - sx
y = ty - sy

r = "R" * x
u = "U" * y
l = "L" * x
d = "D" * y

print("".join([r, u, l, d, "D", r, "R", "U", u, "L", "U", l, "L", "D", d, "R"]))

Submission status: Accepted

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

#1回目 (sx,sy)->(tx,ty)
for i in range(tx-sx):
    print("R",end="")
for i in range(ty-sy):
    print("U",end="")

#2回目 (tx,ty)->(sx,sy)
for i in range(tx-sx):
    print("L",end="")
for i in range(ty-sy):
    print("D",end="")

#3回目 (sx,sy)->(tx,ty)
print("D",end="")
for i in range(tx-sx+1):
    print("R",end="")
for i in range(ty-sy+1):
    print("U",end="")
print("L",end="")

#4回目 (tx,ty)->(sx,sy)
print("U",end="")
for i in range(tx-sx+1):
    print("L",end="")
for i in range(ty-sy+1):
    print("D",end="")
print("R",end="")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def solve(sx,sy,tx,ty):
  dx=tx-sx
  dy=ty-sy
  return 'R'*dx+'U'*dy+'L'*dx+'D'*dy+'D'+'R'*(dx+1)+'U'*(dy+1)+'L'+'U'+'L'*(dx+1)+'D'*(dy+1)+'R'

print(solve(sx,sy,tx,ty))

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    sx, sy, tx, ty = map(int, input().split())
    ans = ""
    for _ in range(ty-sy):
        ans += "U"
    for _ in range(tx-sx):
        ans += "R"

    for _ in range(ty-sy):
        ans += "D"
    for _ in range(tx-sx):
        ans += "L"

    ans += "L"
    for _ in range(ty-sy+1):
        ans += "U"
    for _ in range(tx-sx+1):
        ans += "R"
    ans += "D"

    ans += "R"
    for _ in range(ty-sy+1):
        ans += "D"
    for _ in range(tx-sx+1):
        ans += "L"
    ans += "U"

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
UP = 'U'
DOWN = 'D'
LEFT = 'L'
RIGHT = 'R'

START_CELL = 'S'
TARGET_CELL = 'T'

def main():
    sx, sy, tx, ty = list(map(int, input().split()))
    moves = [
        {'dir': RIGHT, 'dis': tx - sx},
        {'dir': UP, 'dis': ty - sy},

        {'dir': LEFT, 'dis': tx - sx},
        {'dir': DOWN, 'dis': ty - sy},

        {'dir': DOWN, 'dis': 1},
        {'dir': RIGHT, 'dis': tx - sx + 1},
        {'dir': UP, 'dis': ty - sy + 1},
        {'dir': LEFT, 'dis': 1},

        {'dir': UP, 'dis': 1},
        {'dir': LEFT, 'dis': tx - sx + 1},
        {'dir': DOWN, 'dis': ty - sy + 1},
        {'dir': RIGHT, 'dis': 1},
    ]

    for move in moves:
        print(move['dir'] * move['dis'], end='')


main()

Submission status: Accepted

Solution code:
# C - Back and Forth

# 1回目Go上→右、2回目Back下→左、3回目Go左1回→上→右→下1回、4回目Back右1回→下→左→上1回

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

route = ""

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

print(route)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def main():
    sx, sy, tx, ty = map(int, input().split())
    ans = []

    for i 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))


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 +
      'L' + 'U' * (dy + 1) + 'R' * (dx + 1) +\
      'DR' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U')

Submission status: Accepted

Solution code:
import collections
import itertools
import functools
import math

if __name__ == "__main__":
    sx, sy, tx, ty = map(int, input().split())
    dx = tx - sx
    dy = ty - sy
    path = 'U' * dy + 'R' * dx
    path += 'D' * dy + 'L' * dx
    path += 'L' + 'U' * (dy + 1) + 'R' * (dx + 1) + 'D'
    path += 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U'
    print(path)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = tuple(map(int, input().split()))
dx = tx - sx
dy = ty - sy
ans = ""
ans += "U" * dy
ans += "R" * dx
ans += "D" * dy
ans += "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())

x = tx - sx
y = ty - sy

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

print(ans)

Submission status: Accepted

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

    # Path 1
    print("U" * dy + "R" * dx, end='')

    # Path 2
    print("D" * dy + "L" * dx, end='')

    # Path 3
    print("D" + "R" * (dx+1) + "U" * (dy+1) + "L", end='')

    # Path 4
    print("U" + "L" * (dx+1) + "D" * (dy+1) + "R", end='')


if __name__ == '__main__':
    c()

Submission status: Accepted

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

dx = abs(tx - sx)
dy = abs(ty - sy)

ans  = 'U'*dy + 'R'*dx
ans += '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())
y=c-a
x=d-b
#round1
if(x>0):
  for i in range(x):
    print("U",end="")
else:
  for i in range(-x):
    print("D",end="")
if(y>0):
  for i in range(y):
    print("R",end="")
else:
  for i in range(-y):
    print("L",end="")
    
#round2
if(x>0):
  for i in range(x):
    print("D",end="")
else:
  for i in range(-x):
    print("U",end="")
if(y>0):
  for i in range(y):
    print("L",end="")
else:
  for i in range(-y):
    print("R",end="")
    
#round3
if(x>0):
  if(y>0):
    print("L",end="")
  else:
    print("R",end="")
  for i in range(x+1):
    print("U",end="")
else:
  if(y>0):
    print("L",end="")
  else:
    print("R",end="")
  for i in range(-x+1):
    print("D",end="")
    
if(y>0):
  for i in range(y+1):
    print("R",end="")
  if(x>0):
    print("D",end="")
  else:
    print("U",end="")
else:
  for i in range(-y+1):
    print("L",end="")
  if(x>0):
    print("D",end="")
  else:
    print("U",end="")
    
#round4
if(x>0):
  if(y>0):
    print("R",end="")
  else:
    print("L",end="")
  for i in range(x+1):
    print("D",end="")
else:
  if(y>0):
    print("R",end="")
  else:
    print("L",end="")
  for i in range(-x+1):
    print("U",end="")
if(y>0):
  for i in range(y+1):
    print("L",end="")
  if(x>0):
    print("U",end="")
  else:
    print("D",end="")
else:
  for i in range(-y+1):
    print("R",end="")
  if(x>0):
    print("U",end="")
  else:
    print("D",end="")

Submission status: Accepted

Solution code:
sx,sy,tx,ty= map(int, input().split())
s=''
for i in range(tx-sx):
    s+='R'
for i in range(ty-sy):
    s+='U'
for i in range(tx-sx):
    s+='L'
for i in range(ty-sy):
    s+='D'
s+='D'
for i in range(tx-sx+1):
    s+='R'
for i in range(ty-sy+1):
    s+='U'
s+='LU'
for i in range(tx-sx+1):
    s+='L'
for i in range(ty-sy+1):
    s+='D'
s+='R'
print(s)

Submission status: Accepted

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