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())

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())
a = tx-sx
b = ty-sy

c = "R"*a + "U"*b
d = "L"*a + "D"*b
e = "D" + "R"*(a+1) + "U"*(b+1) + "L"
f = "U" + "L"*(a+1) + "D"*(b+1) + "R"

g = c + d + e + f
print(g)
#print(g.count("R"),g.count("L"),g.count("U"),g.count("D"))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc051/tasks/abc051_c
# 同じ座標を複数回通らないようにということなので、始点と終点の上下左右をすべて使うなかで最短経路を提示すれば良い。
# 一番単純なのは時計回りに動くと決め打ちで文字を出力することかな

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

dx = tx - sx
dy = ty - sy
U, D, L, R = 'UDLR'

ans = U * dy + R * dx + D * dy + L * dx  # 一周目
ans += L + U * (1 + dy) + R * (1 + dx) + D + R + \
    D * (1 + dy) + L * (1 + dx) + U  # うち間違えに注意
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = "L"

dx = tx - sx
dy = ty - sy

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
tx=tx-sx
ty=ty-sy
sx=0
sy=0
ans=[]
def add(num,d):
    global ans
    di=["U","D","L","R"]
    for i in range(num):
        ans.append(di[d])
y=ty-sy
x=tx-sx
add(y,0)
add(x,3)
add(y,1)
add(x,2)
add(1,2)
add(y+1,0)
add(x+1,3)
add(1,1)
add(1,3)
add(y+1,1)
add(x+1,2)
add(1,0)
print("".join(ans))

Submission status: Accepted

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

if __name__ == "__main__":
    sx,sy,tx,ty = map(int,readline().split())
    ans = ""
    #tx,tyは必ず右上にあることが言える
    ans += "U"*(ty-sy)
    ans += "R"*(tx-sx)
    ans += "D"*(ty-sy)
    ans += "L"*(tx-sx)
    ans += "L"
    ans += "U"*(ty-sy+1)
    ans += "R"*(tx-sx+1)
    ans += "D"
    ans += "R"
    ans += "D"*(ty-sy+1)
    ans += "L"*(tx-sx+1)
    ans += "U"
    print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
dx = tx-sx
dy = ty-sy
ans = []
for i in range(dx):
    ans.append('R')

for i in range(dy):
    ans.append('U')

for i in range(dx):
    ans.append('L')

for i in range(dy+1):
    ans.append('D')

for i in range(dx+1):
    ans.append('R')

for i in range(dy+1):
    ans.append('U')

ans.append("LU")
for i in range(dx+1):
    ans.append('L')

for i in range(dy+1):
    ans.append('D')

ans.append('R')
print("".join(ans))

Submission status: Accepted

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

nowx, nowy = sx, sy

ans = ''

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    coordinates = list(map(int, input().split()))
    dx = coordinates[2] - coordinates[0]
    dy = coordinates[3] - coordinates[1]
    answer = "R" * dx + "U" * dy + "L" * dx + "D" * dy
    dx += 1
    dy += 1
    answer += "L" + "U" * dy + "R" * dx + "D" + "R" + "D" * dy + "L" * dx + "U"
    print(answer)


if __name__ == '__main__':
    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:
x, y, tx, ty = map(int, input().split())

# xy軸方向それぞれの距離
dx = abs(tx - x)
dy = abs(ty - y)

s = ''

# 1回目の往復は(x, y)から右にdx, 上にdy、(tx, ty)から左にdx, 下にdy移動する
s += 'R'*dx + 'U'*dy + 'L'*dx + 'D'*dy

# ２回目の往復は1回目とは別の座標を通るので最短で4座標遠回りする
# 行きは、１座標下に、(dx+1)右に、(dy+1)上に、1座標左に、
# 帰りは、1座標上に、(dx+1)左に、(dy+1)下に、1座標右に移動する
s += 'D' + 'R'*(dx+1) + 'U'*(dy+1) + 'L' + 'U' + 'L'*(dx+1) + 'D'*(dy+1) + 'R'

print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
def pans(l,c):
    for i in range(l):
        print(c,end="")
H=ty-sy
W=tx-sx
pans(H,"U")
pans(W,"R")
pans(H,"D")
pans(W+1,"L")
pans(H+1,"U")
pans(W+1,"R")
pans(1,"D")
pans(1,"R")
pans(H+1,"D")
pans(W+1,"L")
pans(1,"U")

Submission status: Accepted

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

tx = tx - sx
ty = ty - sy

ans = "" 
ans += "U" * ty
ans += "R" * tx
ans += "D" * ty
ans += "L" * tx
ans += "L"
ans += "U" * (ty + 1)
ans += "R" * (tx + 1)
ans += "D"
ans += "R"
ans += "D" * (ty + 1)
ans += "L" * (tx + 1)
ans += "U"

print(ans)

Submission status: Accepted

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

result = ""
dy = ty-sy
dx = tx-sx

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

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

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

Submission status: Accepted

Solution code:
Sx, Sy, Tx, Ty = map(int, input().split())

for i in range(2):
    print("L"*i, end="")
    print("U"*((Ty-Sy)+i), end="")
    print("R"*((Tx-Sx)+i), end="")
    print("D"*i, end="")
    print("R"*i, end="")
    print("D"*((Ty-Sy)+i), end="")
    print("L"*((Tx-Sx)+i), end="")
    print("U"*i, end="")

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

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

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:
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())

x=tx-sx
y=ty-sy

for i in range(x):
    print("R",end="")

for i in range(y):
    print("U",end="")


for i in range(x):
    print("L",end="")

for i in range(y):
    print("D",end="")
#iki
print("D",end="")
for i in range(x+1):
    print("R",end="")

for i in range(y+1):
    print("U",end="")
print("L",end="")




print("U",end="")
for i in range(x+1):
    print("L",end="")

for i in range(y+1):
    print("D",end="")
print("R",end="")

Submission status: Accepted

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

ans = ""
count = 0

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

width = tx - sx
height = ty - sy

ans_str = ''

ans_str += 'R' * width
ans_str += 'U' * height
ans_str += 'L' * width
ans_str += 'D' * height

ans_str += 'D'
ans_str += 'R' * (width+1)
ans_str += 'U' * (height+1)
ans_str += 'L'

ans_str += 'U'
ans_str += 'L' * (width+1)
ans_str += 'D' * (height+1)
ans_str += 'R'

print(ans_str)

Submission status: Accepted

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

diff_x = tx-sx
diff_y = ty-sy

first_path = 'U'*diff_y + 'R'*diff_x + 'D'*diff_y + 'L'*diff_x
second_path = 'L' + 'U'*diff_y + 'U' + 'R' + 'R'*diff_x + 'D' + \
              'R' + 'D'*diff_y + 'D' + 'L' + 'L'*diff_x + 'U'


print(first_path+second_path)

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

Submission status: Accepted

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

res += "U" * (y2-y1)
res += "R" * (x2-x1)
res += "D" * (y2-y1)
res += "L" * (x2-x1)
res += "L" + "U" * (y2-y1 + 1)
res += "R" * (x2-x1 + 1) + "D"

res += "R" + "D" * (y2-y1 + 1)
res += "L" * (x2-x1 + 1) + "U"


print(res)

Submission status: Accepted

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

for i in range(4):
    if i==2:
        ans+="L"
        dx+=1
        dy+=1
    elif i==3:
        ans+="DR"
    if dy>=0:
        ans+="U"*dy
        dy=dy*(-1)
    else:
        ans+="D"*(dy*(-1))
        dy=dy*(-1)
    if dx>=0:
        ans+="R"*dx
        dx=dx*(-1)
    else:
        ans+="L"*(dx*(-1))
        dx=dx*(-1)
ans+="U"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

    tx = tx - sx
    ty = ty - sy

    def f1():
        s = ""
        s = s + "U" * ty
        s = s + "R" * tx
        return s

    def b1():
        s = ""
        s = s + "D" * ty
        s = s + "L" * tx
        return s

    def f2():
        s = ""
        s = s + "L" + "U" * (ty + 1)
        s = s + "R" * (tx + 1) + "D"
        return s

    def b2():
        s = ""
        s = s + "R" + "D" * (ty + 1)
        s = s + "L" * (tx + 1) + "U"
        return s

    print(f1() + b1() + f2() + b2())


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    X, Y, TX, TY = map(int, input().split())
    DX = TX - X
    DY = TY - Y
    result = ''
    result += 'U' * DY + 'R' * DX
    result += 'D' * DY + 'L' * DX
    result += 'L' + 'U' * (DY + 1) + 'R' * (DX + 1) + 'D'
    result += 'R' + 'D' * (DY + 1) + 'L' * (DX + 1) + 'U'
    print(result)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

mv_x = tx - sx
mv_y = ty - sy

ans = ''
ans += 'R' * mv_x + 'U' * mv_y
ans += 'L' * mv_x + 'D' * mv_y
ans += 'D' + 'R' * (mv_x+1) + 'U' * (mv_y+1) + 'L'
ans += 'U' + 'L' * (mv_x+1) + 'D' * (mv_y + 1) + 'R'

print(ans)

Submission status: Accepted

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

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

mov_x = tx - sx
mov_y = ty - sy

ans = ''
ans += 'R' * mov_x
ans += 'U' * mov_y
ans += 'L' * mov_x
ans += 'D' * mov_y
ans += 'D'
ans += 'R' * (mov_x + 1)
ans += 'U' * (mov_y + 1)
ans += 'L'
ans += 'U'
ans += 'L' * (mov_x + 1)
ans += 'D' * (mov_y + 1)
ans += 'R'
print(ans)

Submission status: Accepted

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

ans += 'U'*(y) + 'R'*(x)
ans += '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:
sx,sy,tx,ty=map(int,input().split())

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

Submission status: Accepted

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

ans=""
y=ty-sy
x=tx-sx

#1往復目
ans +="U"*y
ans +="R"*x
ans +="D"*y
ans +="L"*x
#2往復目(+1は1往復目との重複を避けるために1ずらしている。)
ans +="L"
ans +="U"*(y+1)
ans +="R"*(x+1)
ans +="D"
ans +="R"
ans +="D"*(y+1)
ans +="L"*(x+1)
ans +="U"

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x0, y0, x1, y1 = map(int, input().split())
print(
    "R" * (x1 - x0)
    + "U" * (y1 - y0)
    + "L" * (x1 - x0)
    + "D" * (y1 - y0)
    + "D"
    + "R" * (x1 - x0)
    + "R"
    + "U"
    + "U" * (y1 - y0)
    + "L"
    + "U"
    + "L" * (x1 - x0)
    + "L"
    + "D"
    + "D" * (y1 - y0)
    + "R"
)

Submission status: Accepted

Solution code:
a,b,c,d = map(int, input().split())
#sを(0,0)にする
#s = (a + (0 - a), b + (0 - b))
#g = (c + (0 - a), d + (0 - b))
s = (a, b)
g = (c, d)

route = []

#turn1 ->g
route.append('R' * (g[0] - s[0]))
route.append('U' * (g[1] - s[1]))
#turn1 ->s
route.append('L' * (g[0] - s[0]))
route.append('D' * (g[1] - s[1]))
#turn2 ->g
route.append('D')
route.append('R' * (g[0] - s[0] + 1))
route.append('U' * (g[1] - s[1] + 1))
route.append('L')
#turn2 ->s
route.append('U')
route.append('L' * (g[0] - s[0] + 1))
route.append('D' * (g[1] - s[1] + 1))
route.append('R')


route = "".join(route)
print(route)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx, sy, tx, ty = [int(n) for n in input().split()]
dx = tx - sx
dy = ty - sy
print('U'*dy+'R'*dx, end="")
print('D'*dy+'L'*dx, end="")
print('L'+'U'*(dy+1)+'R'*(dx+1)+'D', end="")
print('R'+'D'*(dy+1)+'L'*(dx+1)+'U')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
SX,SY,TX,TY=map(int,input().split())
NX=TX-SX
NY=TY-SY
ans=[]
for i in range(NX):
  ans.append('R')
for i in range(NY):
  ans.append('U')
for i in range(NX):
  ans.append('L')
for i in range(NY):
  ans.append('D')
ans.append('D')
for i in range(NX+1):
  ans.append('R')
for i in range(NY+1):
  ans.append('U')
ans.append('L')
ans.append('U')
for i in range(NX+1):
  ans.append('L')
for i in range(NY+1):
  ans.append('D')
ans.append('R')
print(''.join(ans))

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split())
A=[]
if (d-b)>0:
  A.append('U'*(d-b))
else:
  A.append('D'*(b-d))

if (c-a)>0:
  A.append('R'*(c-a))
else:
  A.append('L'*(a-c))

if (d-b)>0:
  A.append('D'*(d-b))
else:
  A.append('U'*(b-d))

if (c-a)>0:
  A.append('L'*(c-a+1))
else:
  A.append('R'*(a-c+1))  

if (d-b)>0:
  A.append('U'*(d-b+1))
else:
  A.append('D'*(b-d+1))

if (c-a)>0:
  A.append('R'*(c-a+1))
else:
  A.append('L'*(a-c+1))  
  
if (d-b)>0:
  A.append('D')
else:
  A.append('U')

if (c-a)>0:
  A.append('R')
else:
  A.append('L')
  
if (d-b)>0:
  A.append('D'*(d-b+1))
else:
  A.append('U'*(b-d+1))  
  
if (c-a)>0:
  A.append('L'*(c-a+1))
else:
  A.append('R'*(a-c+1))  
  
if (d-b)>0:
  A.append('U')
else:
  A.append('D')
print(*A,sep='')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
X = ["L", "R"]
Y = ["D", "U"]
if sx == tx or sy == ty:
    if sy == ty:
        X, Y = Y, X
        sy, ty = sx, tx
    dy = abs(ty - sy)
    d = sy < ty
    nd = sy > ty
    ans = Y[d]*(dy+1)+X[0]*2+Y[nd]*(dy+2)+X[1]*2+Y[d]+X[0]+Y[d]*dy+X[1]*2+Y[nd]*dy+X[0]
else:
    dx = abs(tx-sx)
    dy = abs(ty-sy)
    xd = sx < tx
    yd = sy < ty
    ans = Y[yd]*dy+X[xd]*dx+Y[not yd]*dy+X[not xd]*(dx+1)+Y[yd]*(dy+1)+X[xd]*(dx+1)+Y[not yd]+X[xd]+Y[not yd]*(dy+1)+X[not xd]*(dx+1)+Y[yd]
print(ans)

Submission status: Accepted

Solution code:

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

ans = ""

y = (ty - sy) 
x = (tx - sx)

# 一周目
ans += "U" * y
ans += "R" * x
ans += "D" * y
ans += "L" * x

# 二周目
ans += "L"
ans += "U" * (y + 1)
ans += "R" * (x + 1)
ans += "D"
ans += "R"
ans += "D" * (y + 1)
ans += "L" * (x + 1)
ans += "U"

print(ans)

Submission status: Accepted

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

tx-=sx
ty-=sy

res=[]

for i in range(ty):
    res.append("U")
for i in range(tx+1):
    res.append("R")
for i in range(ty+1):
    res.append("D")
for i in range(tx+1):
    res.append("L")
res.append("U")

res.append("L")
for i in range(ty+1):
    res.append("U")
for i in range(tx+1):
    res.append("R")
for i in range(ty+1):
    res.append("D")
for i in range(tx):
    res.append("L")

for i in res:
    print(i,end='')

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
u="U"
d="D"
r="R"
l="L"
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:
sx,sy,tx,ty = map(int, input().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

ans=[]
#1
ans+='R'*(tx-sx)
ans+='U'*(ty-sy)

#2
ans+='L'*(tx-sx)
ans+='D'*(ty-sy)

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

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


print(''.join(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math

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

dy=ty-sy
dx=tx-sx

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

print(a)

Submission status: Accepted

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

ans = ""
ans2 = ""

for u in range(ty - sy):
    ans += "U"
for r in range(tx - sx):
    ans += "R"

ans2 = "LU" + ans + "RD"

print(ans + ans.translate(str.maketrans('UR', 'DL')) + ans2 + ans2.translate(str.maketrans('URDL', 'DLUR')))

Submission status: Accepted

Solution code:
SX, SY, TX, TY = map(int, input().split())
way1 = 'U' * (TY - SY) + 'R' * (TX - SX)
way2 = 'D' * (TY - SY)+ 'L' * (TX - SX)
way3 = 'L' + 'U' * (TY - SY + 1) + 'R' * (TX - SX + 1) + 'D'
way4 = 'R' + 'D' * (TY - SY + 1) + 'L' * (TX - SX + 1) + 'U'
print(way1 + way2 + way3 + way4)

Submission status: Accepted

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

for i in range(tx - sx):
    print("R",end="")

for i in range(ty - sy):
    print("U",end="")

for i in range(tx - sx):
    print("L",end="")

for i in range(ty - sy):
    print("D",end="")

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="")
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:

#2041~
import sys
[a,b,c,d] = list(map(int,input().split()))

#print(a,b,c,d)

#たて
e=d-b
#横
f=c-a

g=""

for i in range(e):
    g=g+"U"
for i in range(f):
    g=g+"R"

for i in range(e):
    g=g+"D"
for i in range(f):
    g=g+"L"

g=g+"L"
for i in range(e+1):
    g=g+"U"
for i in range(f+1):
    g=g+"R"
g=g+"D"

g=g+"R"
for i in range(e+1):
    g=g+"D"
for i in range(f+1):
    g=g+"L"
g=g+"U"

print(g)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int,input().split())
keiro = ""
for i in range(ty-sy):
    keiro += "U"
for i in range(tx-sx):
    keiro += "R"
keiro0 = keiro
keiro = ""
for i in range(ty-sy):
    keiro += "D"
for i in range(tx-sx):
    keiro += "L"
keiro1 = keiro

ans = keiro0+keiro1+"LU"+keiro0+"RDRD"+keiro1+"LU"

print(ans)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    sx, sy, tx, ty = [int(x) for x in input().split()]

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(sx: int, sy: int, tx: int, ty: int):

    dirc = ["U", "D", "L", "R"]
    ans = []
    # 1
    if sx > tx:
        dirc[2] = "R"
        dirc[3] = "L"
    if sy > ty:
        dirc[0] = "D"
        dirc[1] = "U"

    ans += [dirc[3]]*(tx-sx)
    ans += [dirc[0]]*(ty-sy)

    ans += [dirc[2]]*(tx-sx)
    ans += [dirc[1]]*(ty-sy)

    ans += [dirc[1]]
    ans += [dirc[3]]*(tx-sx+1)
    ans += [dirc[0]]*(ty-sy+1)
    ans += [dirc[2]]

    ans += [dirc[0]]
    ans += [dirc[2]]*(tx-sx+1)
    ans += [dirc[1]]*(ty-sy+1)
    ans += [dirc[3]]

    print("".join(ans))

    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:
import sys

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

root = ""

# 1回目の　s => t
# まず、Y座標分上がる
root += "U" * (ty - sy)
# X座標分分右に移動
root += "R" * (tx - sx)

# 1回目の t => s
# まず、Y座標分下がる
root += "D" * (ty - sy)
# X座標分左に戻る
root += "L" * (tx - sx)

# 2回目の　s => t (sx - 1, sy) => (tx, ty + 1)
# まず、X座標に左に１つ移動し、座標分上がる
root += "L"
root += "U" * ((ty + 1) - sy)
# X座標分右に移動、Y座標を１つ下がる
root += "R" * (tx - (sx - 1))
root += "D"

# 2回目の t => s (tx + 1, ty) => (sx, sy - 1)
# まず、X座標に右に１つ移動し、Y座標分下がる
root += "R"
root += "D" * (ty - (sy - 1))
# X座標分左に移動し、Y座標を１つ上がる
root += "L" * ((tx + 1)  - sx)
root += "U"

print(root)

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:
if __name__ == '__main__':
	sx, sy, tx, ty = map(int, input().split())
	h = ty - sy
	w = tx - sx

	ans = ''

	for i in range(0,2):
		if i == 0:
			ans += 'LU'
		for j in range(0,h):
			ans += 'U'
		for j in range(0,w):
			ans += 'R'
		if i == 0:
			ans += 'RD'

		if i == 0:
			ans += 'RD'
		for j in range(0,h):
			ans += 'D'
		for j in range(0,w):
			ans += 'L'
		if i == 0:
			ans += 'LU'

	print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:


def main():
    sx ,sy, tx, ty = map(int ,input().split())
    for i in range(sx,tx):
        print('R',end="")
    for i in range(sy,ty):
        print('U',end="")
    for i in range(sx,tx):
        print('L',end="")
    for i in range(sy,ty + 1):
        print('D',end="")
    for i in range(sx,tx + 1):
        print('R',end="")
    for i in range(sy,ty + 1):
        print('U',end="")
    print('L',end="")
    print('U',end="")
    for i in range(sx,tx + 1):
        print('L',end="")
    for i in range(sy,ty + 1):
        print('D',end="")
    print('R')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy

txt = ""

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

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

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

print(txt)

Submission status: Accepted

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

# return
ans += "U" * gy + "R" * gx
ans += "U" + "L" * (gx + 1) + "D" * (gy + 1) + "R"

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sx, sy, tx, ty = [int(x) for x in input().split()]
dx = tx - sx
dy = ty - sy

lr = ["0", "R", "L"]
ud = ["0", "U", "D"]

lr_idx = 1 if dx > 0 else 2
ud_idx = 1 if dy > 0 else 2

first = lr[lr_idx] * abs(dx) + ud[ud_idx] * abs(dy)
second = lr[-lr_idx] * abs(dx) + ud[-ud_idx] * abs(dy)
third = ud[-ud_idx] + lr[lr_idx] + first + ud[ud_idx] + lr[-lr_idx]
fourth = ud[ud_idx] + lr[-lr_idx] + second + ud[-ud_idx] + lr[lr_idx]

print(first + second + third + fourth)

Submission status: Accepted

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