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
tmp=""
tmp+="U"*dy+"R"*dx+"D"*dy+"L"*dx
tmp+="L"+"U"*(dy+1)+"R"*(dx+1)+"D"+"R"+"D"*(dy+1)+"L"*(dx+1)+"U"
print(tmp)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sx, sy, tx, ty = map(int, input().split())
f = []
s = []
r = 0
u = 0
for i in range(abs(tx - sx)):
  if sx < tx:
    f.append("R")
    r = 1
  else: f.append("L")
for i in range(abs(ty - sy)):
  if sy < ty:
    f.append("U")
    u = 1
  else: f.append("D")
if u:
  s.append("D")
else:
  s.append("U")
for i in range(abs(tx - sx) + 1):
  if sx < tx:
    s.append("R")
  else: s.append("L")
for i in range(abs(ty - sy) + 1):
  if sy < ty:
    s.append("U")
  else: s.append("D")
if r:
  s.append("L")
else: s.append("R")
f2 = []
s2 = []
for x in f:
  if x == "U": f2.append("D")
  elif x == "D": f2.append("U")
  elif x == "R": f2.append("L")
  else: f2.append("R")
for x in s:
  if x == "U": s2.append("D")
  elif x == "D": s2.append("U")
  elif x == "R": s2.append("L")
  else: s2.append("R")
print("".join(f + f2 + s + s2))

Submission status: Accepted

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

a = tx - sx
b = ty - sy

ans = str()

# 一往復目
ans += 'R' * a
ans += 'U' * b
ans += 'L' * a
ans += 'D' * b

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

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

print(ans)

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy

ans = ""
# path1
ans += "R" * dx + "U" * dy 

# path2
ans += "L" * dx + "D" * dy

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

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

print(ans)

Submission status: Accepted

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

ans = ''
for i in range(ty - sy):
    ans += 'U'
for j in range(tx - sx):
    ans += 'R'
for i in range(ty - sy):
    ans += 'D'
for j in range(tx - sx):
    ans += 'L'
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]=list(map(int,input().split()))
a1=["R"]*(tx-sx)+["U"]*(ty-sy)+["L"]*(tx-sx)+["D"]*(ty-sy)
a2=["D"]+["R"]*(tx-sx+1)+["U"]*(ty-sy+1)+["L"]+["U"]+["L"]*(tx-sx+1)+["D"]*(ty-sy+1)+["R"]
ans=a1+a2
for i in range(len(ans)):
	print(ans[i],end="")

Submission status: Accepted

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    sx, sy, tx, ty = list(map(int, readline().split()))
    ans = []
    for j in range(2):
        if j != 0:
            ans.append("D" if tx - sx >= 0 else "U")
            ans.append("R" if tx - sx >= 0 else "L")

        for i in range(abs(tx - sx)):
            ans.append("R" if tx - sx >= 0 else "L")
        for i in range(abs(ty - sy)):
            ans.append("U" if tx - sx >= 0 else "D")

        if j != 0:
            ans.append("U" if tx - sx >= 0 else "D")
            ans.append("L" if tx - sx >= 0 else "R")
            ans.append("U" if tx - sx >= 0 else "D")
            ans.append("L" if tx - sx >= 0 else "R")

        for i in range(abs(tx - sx)):
            ans.append("L" if tx - sx >= 0 else "R")
        for i in range(abs(ty - sy)):
            ans.append("D" if tx - sx >= 0 else "U")

        if j != 0:
            ans.append("D" if tx - sx >= 0 else "U")
            ans.append("R" if tx - sx >= 0 else "L")
    print("".join(ans))


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy

def _dflip(c):
    return {
        'U': 'R',
        'R': 'U',
        'D': 'L',
        'L': 'D',
    }[c]

def dflip(s):
    return ''.join(map(_dflip, s))

def g(dx, dy):
    return 'R' * dx + 'U' * (dy+1) + 'L' * (dx+1) + 'D' * (dy+1) + 'R'

def f(dx, dy):
    if dx > 0 and dy > 0:
        return g(dx, dy) + dflip(g(dy, dx))
    if dy == 0:
        return 'R' * dx + 'U' + 'L' * dx + 'DD' + 'R' * (dx) + 'URUU' + 'L' * (dx+2) + 'DDR'
    if dx == 0:
        return dflip(f(dy, dx))

print(f(dx, dy))

Submission status: Accepted

Solution code:
s_x, s_y, t_x, t_y = map(int, input().split())
#点のインプット
for i in range(t_x - s_x):
  print("R", end="")
for i in range(t_y - s_y):
  print("U", end="")
for i in range(t_x - s_x):
  print("L", end="")
for i in range(t_y - s_y):
  print("D", end="")
  
t_x = t_x+1
t_y = t_y+1

print("D", end="")
for i in range(t_x - s_x):
  print("R", end="")
for i in range(t_y - s_y):
  print("U", end="")
print("LU", end="")
for i in range(t_x - s_x):
  print("L", end="")
for i in range(t_y - s_y):
  print("D", end="")
print("R")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
sx, sy, tx, ty = [int(i) for i in sys.stdin.readline().split()]
diff_y = abs(ty - sy)
diff_x = abs(tx - sx)
res = "L"
res += (diff_y + 1) * "U"
res += (diff_x + 1) * "R"
res += "D"
res += (diff_x) * "L"
res += (diff_y + 1) * "D"
res += (diff_x + 1) * "R"
res += (diff_y + 1) * "U"
res += "L"
res += (diff_y) * "D"
res += diff_x * "L"
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

ans = ""

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

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

print(ans)

Submission status: Accepted

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

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

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:
if __name__ == '__main__':
    sx,sy,tx,ty=list(map(int,input().split()))
    dif_x=tx-sx
    dif_y=ty-sy
    path=[]

    path.append("R"*abs(dif_x))
    path.append("U"*abs(dif_y))
    path.append("L"*abs(dif_x))
    path.append("D"*abs(dif_y))
    path.append("D")
    path.append("R" * (abs(dif_x) + 1))
    path.append("U" * (abs(dif_y) + 1))
    path.append("L")
    path.append("U")
    path.append("L" * (abs(dif_x) + 1))
    path.append("D" * (abs(dif_y) + 1))
    path.append("R")
    print("".join(path))

Submission status: Accepted

Solution code:
#n = int(input())
x1, y1, x2, y2 = map(int,input().split())
s = ''
a1 = 'R' * (x2 - x1)
b1 = 'U' * (y2 - y1)
a2 = 'L' * (x2 - x1)
b2 = 'D' * (y2 - y1)
a3 = 'D' + 'R' * (x2 - x1 + 1)
b3 = 'U' * (y2 - y1 + 1) + 'L'
a4 = 'U' + 'L' * (x2 - x1 + 1)
b4 = 'D' * (y2 - y1 + 1) + 'R'
s = a1 + b1 + a2 + b2 + a3 + b3 + a4 + b4
print(s)

Submission status: Accepted

Solution code:
def rotate(s,deg):
    if deg==180:
        return s.translate(str.maketrans({'U': 'D', 'D': 'U', 'L':'R', 'R':'L'}))
    elif deg==90:
        return s.translate(str.maketrans({'U': 'L', 'D': 'R', 'L':'D', 'R':'U'}))
    elif deg==-90:
        return s.translate(str.maketrans({'U': 'R', 'D': 'L', 'L':'U', 'R':'D'}))
def mirror(s,direc):
    if direc=="x":
        return s.translate(str.maketrans({'L':'R', 'R':'L'})) 
    elif direc=="y":
        return s.translate(str.maketrans({'U': 'D', 'D': 'U'}))
def solver1(x,y):
    go="R"*x+"U"*y
    back=rotate(go,180)
    go2="DR"+go+"UL"
    back2="UL"+back+"DR"
    return go+back+go2+back2

a,b,c,d=map(int,input().split())
xf=c-a
yf=d-b
x=abs(c-a)
y=abs(d-b)
print(solver1(x,y))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    sx,sy,tx,ty = map(int, input().split())
    dx = ("R","L") if sx <= tx else ("L","R")
    dy = ("U","D") if sy <= ty else ("D","U")
    lx = abs(sx-tx)
    ly = abs(sy-ty)

    ans = ""
    for i in range(2):
        ans += dy[i]*ly
        ans += dx[i]*lx
   
    for i in range(2):
        inv = (i+1)%2
        ans += dx[inv]
        ans += dy[i]*(ly+1)
        ans += dx[i]*(lx+1)
        ans += dy[inv]

    print(ans)
    #print(len(ans))
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

x_dis = c - a
y_dis = d - b

for i in range(y_dis):
    print('U', end='')

for i in range(x_dis):
    print('R', end='')

for i in range(y_dis):
    print('D', end='')

for i in range(x_dis+1):
    print('L', end='')

for i in range(y_dis+1):
    print('U', end='')

for i in range(x_dis+1):
    print('R', end='')

print('D', end='')
print('R', end='')

for i in range(y_dis+1):
    print('D', end='')

for i in range(x_dis+1):
    print('L', end='')

print('U')

Submission status: Accepted

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

res1 = 'R' * x + 'U' * y
res2 = 'L' * x + 'D' * y
res3 = 'D' + 'R' + res1 + 'U' + 'L'
res4 = 'U' + 'L' + res2 + 'D' + 'R'

res = res1 + res2 + res3 + res4

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

w = tx - sx
h = ty - sy

ans = str()
ans += 'R' * w
ans += 'U' * h
ans += 'L' * w
ans += 'D' * h

ans += 'D'
ans += 'R' * (w + 1)
ans += 'U' * (h + 1)
ans += 'L'

ans += 'U'
ans += 'L' * (w + 1)
ans += 'D' * (h + 1)
ans += 'R'

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin

sx,sy,tx,ty = [int(x) for x in stdin.readline().rstrip().split()]

s = ""

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

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print("".join(ans))

Submission status: Accepted

Solution code:
sx,sy,tx,ty=[int(i) for i in input().split()]
w=tx-sx
h=ty-sy
ans=''

ans+='R'*w
ans+='U'*h
ans+='L'*w
ans+='D'*h

ans+='D'*1
ans+='R'*(w+1)
ans+='U'*(h+1)
ans+='L'*1
ans+='U'*1
ans+='L'*(w+1)
ans+='D'*(h+1)
ans+='R'*1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    ans = ''

    # 1
    for i in range(y2 - y1):
        ans += 'U'
    for i in range(x2 - x1):
        ans += 'R'
    for i in range(y2 - y1):
        ans += 'D'
    for i in range(x2 - x1):
        ans += 'L'

    # 2
    ans += 'L'
    for i in range(y2 - y1 + 1):
        ans += 'U'
    for i in range(x2 - x1 + 1):
        ans += 'R'
    ans += 'D'
    ans += 'R'
    for i in range(y2 - y1 + 1):
        ans += 'D'
    for i in range(x2 - x1 + 1):
        ans += 'L'
    ans += 'U'
    
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

sx,sy,tx,ty=map(int,input().split())
a=["U"]*(ty-sy)+["R"]*(tx-sx)
b=["D"]*(ty-sy)+["L"]*(tx-sx)
c=["L"]+["U"]*(ty-sy+1)+["R"]*(tx-sx+1)+["D"]
d=["R"]+["D"]*(ty-sy+1)+["L"]*(tx-sx+1)+["U"]
ans=a+b+c+d
print("".join(ans))

Submission status: Accepted

Solution code:
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+='DR'
for _ in range(ty-sy+1):
  ans+='D'
for _ in range(tx-sx+1):
  ans+='L'
ans+='U'
print(ans)

Submission status: Accepted

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

pass1 = "U"*dy + "R"*dx
pass2 = "D"*dy + "L"*dx
pass3 = "L" + "U"*(dy+1) + "R"*(dx+1) + "D"
pass4 = "R" + "D"*(dy+1) + "L"*(dx+1) + "U"
print(pass1 + pass2 + pass3 + pass4)

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)
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_d = tx - sx
y_d = ty - sy

print("R"*x_d + "U"*y_d + "L"*x_d + "D"*(y_d + 1) + "R"*(x_d + 1) +
     "U"*(y_d + 1) + "L" + "U" + "L"*(x_d + 1) + "D"*(y_d + 1) + "R")

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+1) + "R" * (x + 1) + "U" * (y + 1) + "L" + "U" + "L" * (x + 1) + "D" * (y + 1) + "R")

Submission status: Accepted

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

if sx < tx:
	status[0] = 1
elif sx > tx:
	status[0] = -1

if sy < ty:
	status[1] = 1
elif sy > ty:
	status[1] = -1

# 第一象限
if status[0] == 1 and status[1] == 1:
	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("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="")
	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="")

Submission status: Accepted

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

distance_x = tx - sx
distance_y = ty - sy

# 時計回りで移動することとする
route_str = ''
# 1回目の (sx, sy) -> (tx, ty) -> (sx, sy) は、最短経路で移動する
route_str += 'U' * distance_y
route_str += 'R' * distance_x
route_str += 'D' * distance_y
route_str += 'L' * distance_x
# 2回目は、行きは左上、帰りは右下にそれぞれ1ずつ膨れて移動する
route_str += 'L'
route_str += 'U' * (distance_y + 1)
route_str += 'R' * (distance_x + 1)
route_str += 'D'
route_str += 'R'
route_str += 'D' * (distance_y + 1)
route_str += 'L' * (distance_x + 1)
route_str += 'U'

print(route_str)

Submission status: Accepted

Solution code:
sx,sy,tx,ty = list(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(ty - sy):
    ans.append("D")
for i in range(tx - sx):
    ans.append("L")
#二回目
ans.append("L")
for i in range(ty + 1 - sy):
    ans.append("U")
for i in range(tx + 1 - sx):
    ans.append("R")
ans.append("D")
ans.append("R")
for i in range(ty + 1 - sy):
    ans.append("D")
for i in range(tx + 1 - sx):
    ans.append("L")
ans.append("U")
print("".join(ans))

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split())
x=c-a;y=d-b
l=['R','L','U','D']
t=''
for j in range(2):
  for i in range(x):
    t+=l[j]
  for i in range(y):
    t+=l[j+2]
for j in range(2):
  t+=l[3-j]
  for i in range(x+1):
    t+=l[j]
  for i in range(y+1):
    t+=l[j+2]
  t+=l[1-j]
print(t)

Submission status: Accepted

Solution code:
sx,sy,tx,ty = list(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(ty - sy):
    ans.append("D")
for i in range(tx - sx):
    ans.append("L")
#二回目
ans.append("L")
for i in range(ty + 1 - sy):
    ans.append("U")
for i in range(tx + 1 - sx):
    ans.append("R")
ans.append("D")
ans.append("R")
for i in range(ty + 1 - sy):
    ans.append("D")
for i in range(tx + 1 - sx):
    ans.append("L")
ans.append("U")
print("".join(ans))

Submission status: Accepted

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

output_txt = ''

#1st txt
x1 = tx -sx
if x1 >0:
    txt_x1 = 'R' * x1
else:
    txt_x1 = 'L' * x1
y1 = ty -sy
if y1 >0:
    txt_y1 = 'U' * y1
else:
    txt_y1 = 'D' * y1

#2nd txt
if x1 >0:
    txt_x2 = 'L' * x1
else:
    txt_x2 = 'R' * x1
if y1 >0:
    txt_y2 = 'D' * y1
else:
    txt_y2 = 'U' * y1

#3rd txt
if y1 >0:
    txt_3 = 'D' 
else:
    txt_3 = 'U'

if x1 >0:
    txt_3 += 'R' * x1 + 'R'
else:
    txt_3 += 'L' * x1 + 'L'

if y1 >0:
    txt_3 += 'U' * y1 + 'U'
else:
    txt_3 += 'D' * y1 + 'D'

if x1 >0:
    txt_3 += 'L'
else:
    txt_3 += 'R'


#4th txt
if y1 >0:
    txt_4 = 'U' 
else:
    txt_4 = 'D'

if x1 >0:
    txt_4 += 'L' * x1 + 'L'
else:
    txt_4 += 'R' * x1 + 'R'

if y1 >0:
    txt_4 += 'D' * y1 + 'D'
else:
    txt_4 += 'U' * y1 + 'U'

if x1 >0:
    txt_4 += 'R'
else:
    txt_4 += 'L'

output_txt = txt_x1 + txt_y1 + txt_x2 + txt_y2
print(output_txt+txt_3+txt_4)

Submission status: Accepted

Solution code:
sx,sy,tx,ty = list(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 += "D"
for i in range(tx-sx+1):
    ans += "R"
for i in range(ty-sy+1):
    ans += "U"
ans += "L"
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:
a,b,c,d=map(int,input().split())
s='';t='';p=''
if c-a>=0:
    s+='R'*(c-a);t+='L'*(c-a)
if c-a<0:
    s+='L'*(a-c);t+='R'*(a-c)
if d-b>=0:
    s+='U'*(d-b);t+='D'*(d-b+1)+s[:(c-a)]+s[0]+s[c-a:]+s[-1]
    p+=t[0]+t[-1]+t[0]*(c-a+1)+'D'*(d-b+1)+s[0]
if d-b<0:
    s+='D'*(b-d);t+='U'*(b-d+1)+s[:(c-a)]+s[0]+s[c-a:]+s[-1]
    p+=t[0]+t[-1]+t[0]*(c-a+1)+'U'*(d-b+1)+s[0]
print(s+t+p)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(sx: int, sy: int, tx: int, ty: int):
    x = tx-sx
    y = ty-sy

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

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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())
result=[]
result.append("D")
for i in range(tx-sx+1):
    result.append("R")
for i in range(ty-sy+1):
    result.append("U")
result.append("L")
result.append("U")
for i in range(tx-sx+1):
    result.append("L")
for i in range(ty-sy+1):
    result.append("D")
result.append("R")

for i in range(tx-sx):
    result.append("R")
for i in range(ty-sy):
    result.append("U")

for i in range(tx-sx):
    result.append("L")
for i in range(ty-sy):
    result.append("D")
print("".join(result))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
Sx,Sy,Tx,Ty = map(int,input().split())

dx = Tx - Sx
dy = Ty - Sy

ans1 = "U"*dy + "R"*dx
ans2 = "D"*dy + "L"*dx
ans3 = "L" + "U"*(dy+1) + "R"*(dx+1) + "D"
ans4 = "R" + "D"*(dy+1) + "L"*(dx+1) + "U"

print(ans1 + ans2 + ans3 + ans4)

Submission status: Accepted

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

ans = ""
go = "U"*y+"R"*x
back = "D"*y+"L"*x
a1 = "LU"
a2 = "RDRD"
a3 = "LU"
print(go+back+a1+go+a2+back+a3)

Submission status: Accepted

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

s= ""

xlen = tx - sx
ylen = ty - sy

#iki
for i in range(xlen):
  s += "R"
for i in range(ylen):
  s +="U"

#kaeri
for i in range(xlen):
  s += "L"
for i in range(ylen):
  s +="D"

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

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

ans = ""
for j in range(ty-sy):
    ans += "U"
for i in range(tx-sx):
    ans += "R"
for j in range(ty-sy):
    ans += "D"
for i in range(tx-sx+1):
    ans += "L"
for j in range(ty-sy+1):
    ans += "U"
for i in range(tx-sx+1):
    ans += "R"
ans += "D"
ans += "R"
for j 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())
lst=""
for i in range(tx-sx):
    lst+="R"
for i in range(ty-sy):
    lst+="U"
for i in range(tx-sx):
    lst+="L"
for i in range(ty-sy):
    lst+="D"
lst+="D"
for i in range(tx-sx +1):
    lst+="R"
for i in range(ty-sy +1):
    lst+="U"
lst+="L"
lst+="U"
for i in range(tx-sx +1):
    lst+="L"
for i in range(ty-sy +1):
    lst+="D"
lst+="R"
print(lst)

Submission status: Accepted

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

xdif=tx-sx
ydif=ty-sy

S="R"*xdif+"U"*ydif+"L"*xdif+"D"*ydif
S=S+"D"+"R"*(xdif+1)+"U"*(ydif+1)+"LU"+"L"*(xdif+1)+"D"*(ydif+1)+"R"
print(S)

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
R_go='R'*(tx-sx)
L_go='L'*(tx-sx)
U_go='U'*(ty-sy)
D_go='D'*(ty-sy)

cycle1=R_go+U_go+L_go+D_go
cycle2_1="D"+R_go+"R"+"U"+U_go+"L"
cycle2_2="U"+L_go+"L"+"D"+D_go+"R"
print(cycle1+cycle2_1+cycle2_2)

Submission status: Accepted

Solution code:
def examC():
    sx, sy, tx, ty = LI()
    ans = ""
    k = 1
    for _ in range(2):
        if k==-1:
            ans = ans + "L"
            ty +=1; tx +=1

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

        if k==1:
            ans = ans + "D"
            ans = ans + "R"

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

        if k==1:
            ans = ans + "U"
    print("".join(map(str,ans)))

import sys
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Submission status: Accepted

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


if __name__ == '__main__':
    main()