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())
route = []


def route_go(sx, sy, tx, ty):
    road_go = []
    for _ in range(tx-sx):
        road_go.append('R')
    for _ in range(ty-sy):
        road_go.append('U')
    return road_go


def route_back(sx, sy, tx, ty):
    road_back = []
    for _ in range(tx-sx):
        road_back.append('L')
    for _ in range(ty-sy):
        road_back.append('D')
    return road_back


a = route_go(sx, sy, tx, ty)
b = route_back(sx, sy, tx, ty)
c = route_go(sx, sy-1, tx+1, ty)
d = route_back(sx-1, sy, tx, ty+1)
e = a + b + ['D'] + c + ['L'] + ['U'] + d +['R']
for i in e:
    print(i, end='')

Submission status: Accepted

Solution code:
x1,y1,x2,y2 = map(int ,input().split())
x = x2 - x1
y = y2 - y1
ans = ''
a = 'U'
b = 'D'
c = 'R'
d = 'L'


for _ in range(y):
    ans += a
for _ in range(x):
    ans += c
for _ in range(y):
    ans += b
for _ in range(x) :
    ans += d
ans += d
for _ in range(y + 1):
    ans += a
for _ in range(x +1):
    ans += c
ans += b
ans += c
for _ in range(y + 1):
    ans += b
for _ in range(x + 1):
    ans += d
ans += a
print(ans)

Submission status: Accepted

Solution code:
sx,sy,gx,gy=map(int,input().split())

ans=""

#行きn=1右,上
ans+="R"*(gx-sx)
ans+="U"*(gy-sy)

#帰りn=1左,下
ans+="L"*(gx-sx)
ans+="D"*(gy-sy)

#行きn=2下,右+1,上+1,左
ans+="D"
ans+="R"*(gx-sx+1)
ans+="U"*(gy-sy+1)
ans+="L"

#帰りn=2上,左+1,下+1,右
ans+="U"
ans+="L"*(gx-sx+1)
ans+="D"*(gy-sy+1)
ans+="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+1)+'U'*(ty-sy+1)+'R'*(tx-sx+1)+'DR'+'D'*(ty-sy+1)+'L'*(tx-sx+1)+'U')

Submission status: Accepted

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

ans = ""
first = "R"*(tx-sx) + "U"*(ty-sy)
second = "L"*(tx-sx) + "D"*(ty-sy)
third = "DR" + first + "UL"
fourth = "UL" + second + "DR"

ans = first + second + third + fourth
print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = (int(i) for i in input().split())
s=""
x = sx
y = sy
while y!=ty:
    y+=1
    s+="U"
while x!=tx:
    x+=1
    s+="R"
while y!=sy:
    y-=1
    s+="D"
while x!=sx:
    x-=1
    s+="L"
x-=1
s+="L"
while y!=ty+1:
    y+=1
    s+="U"
while x!=tx:
    x+=1
    s+="R"
y-=1
s+="D"
x+=1
s+="R"
while y!=sy-1:
    y-=1
    s+="D"
while x!=sx:
    x-=1
    s+="L"
s+=("U")
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def diff(a: tuple, b: tuple) -> int:
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


sx, sy, tx, ty = map(int, input().split())
start = (1, 1)
target = (tx - sx + start[0], ty - sy + start[1])

visited = [[False] * (ty - sy + 3) for _ in range(tx - sx + 3)]
now = start
dic = dict()
ans = ""


dic['U'] = (0, 1)
dic['D'] = (0, -1)
dic['L'] = (-1, 0)
dic['R'] = (1, 0)

for turn in range(4):
    if turn % 2 == 0:
        goal = target
    else:
        goal = start

    while now != goal:
        cnddt = []
        for k in "UDLR":
            nxt = (now[0] + dic[k][0], now[1] + dic[k][1])
            if nxt[0] < 0 or target[0] + 1 < nxt[0]:
                pass
            elif nxt[1] < 0 or target[1] + 1 < nxt[1]:
                pass
            elif nxt == goal or not visited[nxt[0]][nxt[1]]:
                cnddt.append((k, diff(nxt, goal) - diff(now, goal)))
        cnddt = sorted(cnddt, key=lambda x: x[1])
        k = cnddt[0][0]
        ans += k
        nxt = (now[0] + dic[k][0], now[1] + dic[k][1])
        visited[nxt[0]][nxt[1]] = True
        now = nxt

print(ans)

Submission status: Accepted

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

'''
route1 : R * (tx - sx) -> U * (ty - sy)
route2 : L * (tx - sx) -> D * (ty - sy)
route3 : D * 1 -> R * (tx - sx + 1) -> U * (ty - sy + 1) + L * 1
route4 : U * 1 -> L * (ty - sy + 1) -> D * (tx - sx + 1) + R * 1
'''

ans = []
sax = tx - sx
say = ty - sy

for i in range(sax):
    ans.append('R')

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

for i in range(sax):
    ans.append('L')
    
for i in range(say):
    ans.append('D')

ans.append('D')

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

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

ans.append('L')

ans.append('U')

for i in range(sax + 1):
    ans.append('L')

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

ans.append('R')

print(''.join(ans))

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:
A,B,C,D=map(int,input().split())
ans=''
for a in range(C-A) :
	ans=ans+'R'
for a in range(D-B) :
	ans=ans+'U'
for a in range(C-A) :
	ans=ans+'L'
for a in range(D-B) :
	ans=ans+'D'
ans=ans+'L'
for a in range(D-B+1) :
	ans=ans+'U'
for a in range(C-A+1) :
	ans=ans+'R'
ans=ans+'D'
ans=ans+'R'
for a in range(D-B+1) :
	ans=ans+'D'
for a in range(C-A+1) :
	ans=ans+'L'
ans=ans+'U'
print(ans)

Submission status: Accepted

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

ans = ""
for _ in range(dy):
    ans += "U"
for _ in range(dx):
    ans += "R"
for _ in range(dy):
    ans += "D"
for _ in range(dx):
    ans += "L"
ans += "L"

for _ in range(dy + 1):
    ans += "U"
for _ in range(dx + 1):
    ans += "R"
ans += "D"
ans += "R"

for _ in range(dy + 1):
    ans += "D"
for _ in range(dx + 1):
    ans += "L"
ans += "U"

print(ans)

Submission status: Accepted

Solution code:
def main():
    sx, sy, tx, ty = map(int, 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')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
nsx, nsy = sx, sy
while nsy < ty:
    nsy += 1
    print("U", end = "")
while nsx <= tx:
    nsx += 1
    print("R", end = "")
while nsy >= sy:
    nsy -= 1
    print("D", end="")
while nsx > sx:
    nsx -= 1
    print("L", end = "")
nsy += 1
print("U", end = "")
nsx -= 1
print("L", end = "")
while nsy <= ty:
    nsy += 1
    print("U", end = "")
while nsx < tx:
    nsx += 1
    print("R", end = "")
while nsy > sy:
    nsy -= 1
    print("D", end="")
while nsx > sx:
    nsx -= 1
    print("L", end = "")

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int,input().split())
h = ty-sy
w = tx-sx
ans = ""
def f(k, ch):
    global ans
    for i in range(k):
        ans += ch

f(h, "U")
f(w, "R")
f(h, "D")
f(w, "L")
f(1, "L")
f(h+1, "U")
f(w+1, "R")
f(1, "D")
f(1, "R")
f(h+1, "D")
f(w+1, "L")
f(1, "U")
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

H = tx - sx
W = ty - sy

r1 = ["U" for i in range(W)]
r2 = ["D" for i in range(W)]
for i in range(H):
    r1 += "R"
    r2 += "L"
STR1 = ''.join(r1)
STR2 = ''.join(r2)
print(STR1+STR2+"LU"+STR1+"RDRD"+STR2+"LU")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split())
ans ='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'
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx, sy, tx, ty = (int(i) for i in input().split())  
dx = tx - sx
dy = ty - sy
st = "U"*dy + "R"*dx + "D"*dy + "L"*(dx+1) + "U"*(dy+1) + "R"*(dx+1) + "DR" + "D"*(dy+1) + "L"*(dx+1) + "U"
print(st)

Submission status: Accepted

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

#座標の差分
dx = tx - sx
dy = ty - sy

#s->t(1回目)
for i in range(dx):
    ans += "R"
for i in range(dy):
    ans += "U"
#t->s(2回目)
for i in range(dx):
    ans += "L"
for i in range(dy):
    ans += "D"

#s->t(2回目)
ans += "D"
for i in range(dx+1):
    ans += "R"
for i in range(dy+1):
    ans += "U"
ans += "L"
#t->s(2回目)
ans += "U"
for i in range(dx+1):
    ans += "L"
for i in range(dy+1):
    ans += "D"
ans += "R"

print(ans)

Submission status: Accepted

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

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 + 1):
    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 = [int(_) for _ in input().split()]
dx = tx-sx
dy = ty-sy
print('R'*dx+'U'*(dy+1)+'L'*(dx+1)+'D'*(dy+1)+'R' +
      'D'+'R'*(dx+1)+'U'*(dy+1)+'L'*(dx+1)+'D'*dy)

Submission status: Accepted

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

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

res = []

for _ in range(sx,tx):
    res.append("R")
for _ in range(sy,ty):
    res.append("U")
for _ in range(sx,tx):
    res.append("L")
for _ in range(sy,ty):
    res.append("D")
res.append("D")
for _ in range(sx,tx):
    res.append("R")
res.append("R")
for _ in range(sy,ty):
    res.append("U")
res.append("ULU")
for _ in range(sx,tx):
    res.append("L")
res.append("L")
for _ in range(sy,ty):
    res.append("D")
res.append("DR")

print("".join(res))

Submission status: Accepted

Solution code:
_sx, _sy, _tx, _ty = [int(i) for i in input().split()]
sx, sy, tx, ty = _sx, _sy, _tx, _ty
"""
# 全ての場合を一度tx > sx, ty > syにしてから考える
if sx != tx and sy != ty:
    if tx > sx and ty < sy:
        ty += (ty - sy) * 2
    elif tx < sx and ty > sy:
        tx += (tx - sx) * 2
    elif tx < sx and ty < sy:
        tx += (tx - sx) * 2
        ty += (ty - sy) * 2
elif sx == tx:
    if ty < sy:
        ty += (ty - sy) * 2
else:  # sx==txの形に変換
    if tx < sx:
        tx += (tx - sx) * 2
    sy = sx
    ty = sx
"""
path = ""
# 1回目の行き
for i in range(tx - sx):
    path += "R"
for i in range(ty - sy):
    path += "U"
# 1回目の帰り道
for i in range(tx - sx):
    path += "L"
for i in range(ty - sy):
    path += "D"
# 2回目の行き
path += "D"
for i in range(tx - sx + 1):
    path += "R"
for i in range(ty - sy + 1):
    path += "U"
path += "L"
# 2回目の帰り道
path += "U"
for i in range(tx - sx + 1):
    path += "L"
for i in range(ty - sy + 1):
    path += "D"
path += "R"
"""
else:  # sy == ty
    if tx > sx:
        for i in range(tx - sx):
            path += "U"
        path += "R"
        for i in range(tx - sx):
            path += "D"
        path += "L"
        path += "DRR"
        for i in range(tx - sx + 2):
            path += "U"
        path += "LLDL"
        for i in range(tx - sx):
            path += "D"
        path += "R"
"""
print(path)
"""
if sx != tx and sy != ty:
    if tx > sx:
        for i in range(tx - sx):
            path += "R"
    else:
        for i in range(sx - tx):
            path += "L"
    if ty > sy:
        for i in range(ty - sy):
            path += "U"
    else:
        for i in range(sy - ty):
            path += "D"
    # 帰り道
    if tx > sx:
        for i in range(tx - sx):
            path += "L"
    else:
        for i in range(sx - tx):
            path += "R"
    if ty > sy:
        for i in range(ty - sy):
            path += "D"
    else:
        for i in range(sy - ty):
            path += "U"
    # 2回目の行き
    if tx > sx and ty > sy:
        path += "D"
    elif tx > sx
    if tx > sx:
        for i in range(tx - sx):
            path += "R"
    else:
        for i in range(sx - tx):
            path += "L"
    if ty > sy:
        for i in range(ty - sy):
            path += "U"
    else:
        for i in range(sy - ty):
            path += "D"

elif sx == tx:
    if ty > sy:
        for i in range(ty - sy):
            path += "U"
        path += "R"
        for i in range(ty - sy):
            path += "D"
        path += "L"
    else:
        for i in range(sy - ty):
            path += "D"
        path += "R"
        for i in range(sy - ty):
            path += "U"
        path += "L"
else:  # sy == ty
    if tx > sx:
        for i in range(tx - sx):
            path += "R"
        path += "U"
        for i in range(tx - sx):
            path += "L"
        path += "D"
    else:
        for i in range(sx - tx):
            path += "L"
        path += "U"
        for i in range(sx - tx):
            path += "R"
        path += "D"
print(path)
"""

Submission status: Accepted

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

for _ in range(tx-sx):
    print('R', end = '')

for _ in range(ty-sy):
    print('U', end = '')

for _ in range(tx-sx):
    print('L', end = '')

for _ in range(ty-sy):
    print('D', end = '')

print('D', end = '')

for _ in range(tx-sx+1):
    print('R', end = '')

for _ in range(ty-sy+1):
    print('U', end = '')

print('LU', end='')

for _ in range(tx-sx+1):
    print('L', end = '')

for _ in range(ty-sy+1):
    print('D', end = '')

print('R')

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) + 'DR' + 'D'*(Y+1) + 'L'*(X+1) + 'U' 
print(first+second)

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3

sx, sy, tx, ty = [ int(i) for i in input().split() ]
x = tx - sx
y = ty - sy
s = ''
s += 'U' * y + 'R' * x
s += 'D' * y + 'L' * x
s += 'L' + 'U' * (y+1) + 'R' * (x+1) + 'D'
s += 'R' + 'D' * (y+1) + 'L' * (x+1) + 'U'
print(s)

Submission status: Accepted

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


"""
https://beta.atcoder.jp/contests/abc051/tasks/abc51_c
"""

import sys
import math
from inspect import currentframe

def debug(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=sys.stderr)

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

# 例であるような経路が必ず最短になる
dx = tx - sx
dy = ty - sy

s_to_t_1st = 'U' * dy + 'R' * dx
t_to_s_1st = 'D' * dy + 'L' * dx

# 一度目の経路を迂回する経路
s_to_t_2nd = 'L' + 'U' * (dy + 1) + 'R' * (dx + 1) + 'D'
t_to_s_2nd = 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U'

print(s_to_t_1st + t_to_s_1st + s_to_t_2nd + t_to_s_2nd)

Submission status: Accepted

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

ans = ""
y_len = ty-sy
x_len = tx-sx

for _ in range(y_len):
    ans = ans+"U"

for _ in range(x_len):
    ans = ans+"R"

for _ in range(y_len):
    ans = ans+"D"

for _ in range(x_len):
    ans = ans+"L"

ans = ans+"L"

for _ in range(y_len+1):
    ans = ans+"U"

for _ in range(x_len+1):
    ans = ans+"R"

ans = ans+"D"
ans = ans+"R"

for _ in range(y_len+1):
    ans = ans+"D"

for _ in range(x_len+1):
    ans = ans+"L"

ans = ans+"U"
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    sx, sy, tx, ty = li_input()

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


main()

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split(' '))
h = ty - sy
w = tx - sx
p = 'U'*h+'R'*w
r = 'D'*h+'L'*w
print(p+r+'LU'+p+'RDRD'+r+'LU')

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
px=a[0]
py=a[1]
ans=""
while px!=a[2]:
    ans+="R"
    px+=1
while py!=a[3]:
    ans+="U"
    py+=1
while px!=a[0]:
    ans+="L"
    px-=1
while py!=a[1]:
    ans+="D"
    py-=1
ans+="D"
py-=1
while px!=a[2]+1:
    ans+="R"
    px+=1
while py!=a[3]:
    ans+="U"
    py+=1
ans+="LU"
px-=1
py+=1
while px!=a[0]-1:
    ans+="L"
    px-=1
while py!=a[1]:
    ans+="D"
    py-=1
ans+="R"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx, sy, tx, ty = [int(x) for x in input().split()]
dx = tx - sx
dy = 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:
sx, sy, tx, ty = map( int, input().split())
y = ty - sy
x = tx - sx
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"
print(ans)

Submission status: Accepted

Solution code:
def ud(y):
    if y > 0:
        return 'U' * abs(y)
    else:
        return 'D' * abs(y)
def lr(x):
    if x > 0:
        return 'R' * abs(x)
    else:
        return 'L' * abs(x)

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

dx = tx - sx
dy = ty - sy

dx1 = dx // abs(dx)
dy1 = dy // abs(dy)

strs = ud(dy) + lr(dx) + ud(dy * -1) + lr(dx * -1)
strs += lr(dx1 * -1) + ud(dy + dy1) + lr(dx + dx1) + ud(dy1 * -1)
strs += lr(dx1) + ud((dy + dy1) * -1) + lr((dx + dx1) * -1) + ud(dy1)

print(strs)

Submission status: Accepted

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

pos = (sx, sy)

# s left out -> t top in
print("L", end="")
for i in range(ty - sy + 1): print("U", end="")
for i in range(tx - sx + 1): print("R", end="")
print("D", end="")

# t right out -> s bottom in
print("R", end="")
for i in range(ty - sy + 1): print("D", end="")
for i in range(tx - sx + 1): print("L", end="")
print("U", end="")

# s top out -> t left in
for i in range(ty - sy): print("U", end="")
for i in range(tx - sx): print("R", end="")

# t bottom out -> s right in
for i in range(ty - sy): print("D", end="")
for i in range(tx - sx): print("L", end="")
print("")

Submission status: Accepted

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

for _ in range(tx-sx):
    print('R', end='')

for _ in range(ty-sy):
    print('U', end='')

for _ in range(tx-sx):
    print('L', end='')

for _ in range(ty-sy+1):
    print('D', end='')

for _ in range(tx-sx+1):
    print('R', end='')

for _ in range(ty-sy+1):
    print('U', end='')

print('LU', end='')

for _ in range(tx-sx+1):
    print('L', end='')

for _ in range(ty-sy+1):
    print('D', end='')

print('R')

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

path = ''

#往１復１
for y in range(sy,ty):
    path += 'U'

for x in range(sx,tx):
    path += 'R'

for y in range(sy, ty):
    path += 'D'

for x in range(sx, tx):
    path += 'L'

#往２
path += 'L'
for y in range(sy, ty):
    path += 'U'

path += 'U'
path += 'R'
for x in range(sx, tx):
    path += 'R'
path += 'D'

#復２
path += 'R'
for y in range(sy, ty):
    path += 'D'
path += 'D'

for x in range(sx, tx):
    path += 'L'
path += 'L'
path += 'U'

print(path)

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int, input().strip(' ').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:
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+1):
	ans += 'D'
for i in range(tx-sx+1):
	ans += 'R'
for i in range(ty-sy+1):
	ans += 'U'
ans = ans + ['L' , 'U']
for i in range(tx-sx+1):
	ans += 'L'
for i in range(ty-sy+1):
	ans+= 'D'
ans += 'R'
print(''.join(ans))

Submission status: Accepted

Solution code:
def 解():
    sx,sy,tx,ty = [int(_) for _ in input().split()]

    #スタート地点を{0,0}にする
    tx = tx - sx
    ty = ty - sy


    if tx != 0 and ty != 0:
        if 0 < ty  and  0 < tx :
            aV = ["U","R","D","L"]
            d1 = ty
            d2 = tx
        elif ty < 0 and 0 < tx :
            aV = ["R","D","L","U"]
            d1 = tx
            d2 = -ty
        elif ty < 0 and tx < 0:
            aV = ["D","L","U","R"]
            d1 = -ty
            d2 = -tx
        elif 0 < ty and tx < 0:
            aV = ["L","U","R","D"]
            d1 = -tx
            d2 = ty
        print("".join( [aV[0]*d1,aV[1]*d2,aV[2]*d1,aV[3]*(d2+1),aV[0]*(d1+1),aV[1]*(d2+1),aV[2],aV[1],aV[2]*(d1+1),aV[3] * (d2+1), aV[0]]))
    else:
        if 0 < ty and tx == 0:
            aV = ["U","R","D","L"]
            d1 = ty
            d2 = tx
        elif ty == 0 and 0 < tx :
            aV = ["R","D","L","D"]
            d1 = tx
            d2 = ty
        elif ty < 0 and tx == 0 :
            aV = ["D","L","D","R"]
            d1 = ty
            d2 = tx
        elif ty == 0 and tx < 0 :
            aV = ["L","D","R","D"]
            d1 = tx
            d2 = ty
        print("".join([ aV[0]*d1, aV[1], aV[2] * d1, aV[3] * 2, aV[0] * d1, aV[1], aV[0] , aV[1] * 2 , aV[2] * (d1+2),aV[3] * 2, aV[0]]))

解()

Submission status: Accepted

Solution code:

sx,sy,tx,ty = [int(_) for _ in input().split()]

#スタート地点を{0,0}にする
tx = tx - sx
ty = ty - sy


if tx != 0 and ty != 0:
    aV = ["U","R","D","L"]
    d1 = ty
    d2 = tx
    if ty < 0 and 0 < tx :
        aV = ["R","D","L","U"]
        d1 = tx
        d2 = -ty
    if ty < 0 and tx < 0:
        aV = ["D","L","U","R"]
        d1 = -ty
        d2 = -tx
    if 0 < ty and tx < 0:
        aV = ["L","U","R","D"]
        d1 = -tx
        d2 = ty
    print( aV[0]*d1 + aV[1]*d2 + aV[2]*d1 + aV[3]*(d2+1)
        + aV[0]*(d1+1) + aV[1]*(d2+1) + aV[2] + aV[1] + aV[2]*(d1+1) + aV[3] * (d2+1) + aV[0])
else:
    if 0 < ty and tx == 0:
        aV = ["U","R","D","L"]
        d1 = ty
        d2 = tx
    if ty == 0 and 0 < tx :
        aV = ["R","D","L","D"]
        d1 = tx
        d2 = ty
    if ty < 0 and tx == 0 :
        aV = ["D","L","D","R"]
        d1 = ty
        d2 = tx
    if ty == 0 and tx < 0 :
        aV = ["L","D","R","D"]
        d1 = tx
        d2 = ty
    print( aV[0]*d1 + aV[1] + aV[2] * d1 + aV[3] * 2 + aV[0] * d1 + aV[1] + aV[0] + aV[1] * 2 + aV[2] * (d1+2) + aV[3] * 2 + aV[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(sx, sy, tx, ty):
    way1 = "R" * (tx - sx) + "U" * (ty - sy)
    way2 = "L" * (tx - sx) + "D" * (ty - sy)
    way3 = "D" + "R" * (tx - sx + 1) + "U" * (ty - sy+ 1) + "L"
    way4 = "U" + "L" * (tx - sx + 1) + "D" * (ty - sy+ 1) + "R"
    return way1 + way2 + way3 + way4

if __name__ == "__main__":
    sx, sy, tx, ty = map(int, input().split(" "))
    print(solve(sx, sy, tx, ty))

Submission status: Accepted

Solution code:
def main():
    sx, sy, tx, ty = list(map(int, input().split()))
    dx = tx - sx
    dy = ty - sy
    ans = ''
    # 行き1
    ans += 'U' * dy + 'R' * dx
    # 帰り1
    ans += 'D' * dy + 'L' * dx
    # 行き2
    ans += 'L' + 'U' * (dy + 1) + 'R' * (dx + 1) + 'D'
    # 帰り2
    ans += 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U'
    # 答え
    print(ans)
    

if __name__ == "__main__":
    main()