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:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

sx,sy,tx,ty = mii()

route=[]

route.extend(["U"]*(ty-sy))
route.extend(["R"]*(tx-sx))
route.extend(["D"]*(ty-sy))
route.extend(["L"]*(tx-sx))

route.extend(["L"])
route.extend(["U"]*(ty-sy+1))
route.extend(["R"]*(tx-sx+1))
route.extend(["D"])
route.extend(["R"])
route.extend(["D"]*(ty-sy+1))
route.extend(["L"]*(tx-sx+1))
route.extend(["U"])
print("".join(route))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
xs,ys,xg,yg = map(int,input().split())

ans = ''
for i in range(yg-ys):
    ans += 'U'
for i in range(xg-xs):
    ans += 'R'

for i in range(yg-ys):
    ans += 'D'
for i in range(xg-xs + 1):
    ans += 'L'

for i in range(yg-ys+1):
    ans += 'U'
for i in range(xg-xs+1):
    ans += 'R'
ans += 'DR'

for i in range(yg-ys+1):
    ans += 'D'
for i in range(xg-xs + 1):
    ans += 'L'

ans += 'U'
print(ans)

Submission status: Accepted

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

# 1回目の行きの最短経路
for i in range(ty-sy):
    print('U', end='')

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

# 1回目の帰りの最短経路
for i in range(ty-sy):
    print('D', end='')

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

# 2回目の行きの最短経路
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='')

# 2回目の帰りの最短経路
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:
A,B,C,D = map(int,input().split())
ans = ""
ans += (C-A) * "R" + (D-B) * "U"
ans += (C-A) * "L" + (D-B) * "D"
ans += "L" + (D-B+1) * "U" + (C-A+1) * "R"+ "D"
ans += "R" + (D-B+1) * "D" + (C-A+1) * "L"+ "U"
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    sx, sy, tx, ty = list(map(int, input().split()))
    dx = tx - sx
    dy = ty - sy
    res = "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(res)


if '__main__' == __name__:
    resolve()

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 += "R"
for i in range(dy):
  ans += "U"
for i in range(dx):
  ans += "L"
for i in range(dy+1):
  ans += "D"
for i in range(dx+1):
  ans += "R"
for i in range(dy+1):
  ans += "U"
ans += "LU"
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())

w = tx - sx
h = ty - sy

route = ''

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

print(route)

Submission status: Accepted

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

for i in range(dy):
    root += 'U'
for j in range(dx):
    root += 'R'
for k in range(dy):
    root += 'D'
for j in range(dx):
    root += 'L'
    
root += 'L'

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

for k in range(dy+1):
    root += 'D'
for j in range(dx+1):
    root += 'L'
    
    
root += 'U'    
    
print(root)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


# 全探索
def main():
    sx, sy, tx, ty = MI()
    out = []
    # 1st loop
    out.append('U' * (ty - sy))
    out.append('R' * (tx - sx))
    out.append('D' * (ty - sy))
    out.append('L' * (tx - sx))
    # 2nd loop
    out.append('L')
    out.append('U' * ((ty - sy) + 1))
    out.append('R' * ((tx - sx) + 1))
    out.append('D')
    out.append('R')
    out.append('D' * ((ty - sy) + 1))
    out.append('L' * ((tx - sx) + 1))
    out.append('U')

    print(''.join(out))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
ans = ''
ans += 'U'*(ty-sy)
ans += 'R'*(tx-sx)
ans += 'D'*(ty-sy)
ans += 'L'*(tx-sx)
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())
x=tx-sx
y=ty-sy
print("U"*y+"R"*x+"D"*y+"L"*(x+1)+"U"*(y+1)+"R"*(x+1)+"DR"+"D"*(y+1)+"L"*(x+1)+"U")

Submission status: Accepted

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

first_U_times = ty - sy
for _ in range(first_U_times):
    ans.append('U')
first_R_times = tx - sx
for _ in range(first_R_times):
    ans.append('R')
for _ in range(first_U_times):
    ans.append('D')
for _ in range(first_R_times):
    ans.append('L')

ans.append('L')
for _ in range(first_U_times+1):
    ans.append('U')
for _ in range(first_R_times+1):
    ans.append('R')
ans.append('D')

ans.append('R')
for _ in range(first_U_times+1):
    ans.append('D')
for _ in range(first_R_times+1):
    ans.append('L')
ans.append('U')

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

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


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)
ans+='D'+'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:
x1,y1,x2,y2=(map(int,input().split()))

x=x2-x1
y=y2-y1

ans=[]
ans="U"*y+"R"*x+"D"*y+"L"*x
ans+="L"+"U"*(y+1)+"R"*(x+1)+"D"*1+"R"*1+"D"*(y+1)+"L"*(x+1)+"U"*1
print(ans)

Submission status: Accepted

Solution code:
# back and force
ln = list(map(int, input().split(' ')))
disX = ln[2] - ln[0]
disY = ln[3] - ln[1]
output=''
u='U'
d='D'
r='R'
l='L'
#　一周め
for i in range(disY):
    output+= u
for i in range(disX):
    output+= r
for i in range(disY):
    output+= d
for i in range(disX):
    output+= l
#2週め
output+= l+u
for i in range(disY):
    output+= u
for i in range(disX):
    output+= r
output+= r+d +r+d
for i in range(disY):
    output+= d
for i in range(disX):
    output+= l
output+= l+u
print(output)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc051/tasks/abc051_c
sx, sy, tx, ty = map(int, input().split())

ans = []
ans.append('R' * (tx - sx) + 'U' * (ty - sy))
ans.append('L' * (tx - sx) + 'D' * (ty - sy))
ans.append('D' + 'R' * (tx - sx + 1) + 'U' * (ty - sy + 1) + 'L')
ans.append('U' + 'L' * (tx - sx + 1) + 'D' * (ty - sy + 1) + 'R')
print(''.join(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sX,sY,tX,tY = list(map(int,input().split()))
ans = ""
a1 = 'U' * (tY-sY) + 'R' * (tX-sX)
a2 = 'D' * (tY-sY) + 'L' * (tX-sX)
a3 = "L" + "U" * (tY-sY+1) + "R" * (tX-sX+1) + "D"
a4 = "R" + "D" * (tY-sY+1) +"L" * (tX-sX+1) +"U"
print(a1+a2+a3+a4)

Submission status: Accepted

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

dx = tx-sx
dy = ty-sy

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

print(ans)

Submission status: Accepted

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

def main():
    sx, sy, tx, ty = map(int, readline().rstrip().split())
    r1 = 'U' * (ty-sy) + 'R' * (tx-sx)
    r2 = 'D' * (ty-sy) + 'L' * (tx-sx)
    r3 = 'L' + 'U' * (ty-sy+1) + 'R' * (tx-sx+1) + 'D'
    r4 = 'R' + 'D' * (ty-sy+1) + 'L' * (tx-sx+1) + 'U'
    print(r1 + r2 + r3 + r4)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
distance_x, distance_y = tx-sx, ty-sy
x_now, y_now = sx, sy
up, down, right, left = 'U', 'D', 'R', 'L'

#path1
print(up*distance_y+""+right*distance_x,end="")
#path2
print(down*distance_y+""+left*distance_x,end="")
#path3
print("L"+""+up*(distance_y+1)+""+right*(distance_x+1)+""+"D",end="")
#path4
print("R"+""+down*(distance_y+1)+""+left*(distance_x+1)+""+"U")

Submission status: Accepted

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

Submission status: Accepted

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

if sx < tx:
    flag1 = -1
else:
    flag1 = 1

if sy < ty:
    flag2 = 1
else:
    flag2 = -1

def print_root(x1, y1, x2, y2):

    if y1 < y2:
        print("U" * (y2 - y1), end = "")
    else:
        print("D" * (y1 - y2), end = "")

    if x1 < x2:
        print("R" * (x2 - x1), end = "")
    else:
        print("L" * (x1 - x2), end = "")
    
print_root(sx, sy, tx, ty)
print_root(tx, ty, sx, sy)

print_root(sx, sy, sx + flag1, sy)
print_root(sx + flag1, sy, tx, ty + flag2)
print_root(tx, ty + flag2, tx, ty)

print_root(tx, ty, tx - flag1, ty)
print_root(tx - flag1, ty, sx, sy - flag2)
print_root(sx, sy - flag2, sx, sy)
print()

Submission status: Accepted

Solution code:
sx,sy,tx,ty = list(map(int, input().split()))
lst1 = []
lst2 = []
lst3 = []
lst4 = []

lst1.append("D")
lst1 += ["R" for i in range(tx-sx+1)]
lst1 += ["U" for i in range(ty-sy+1)]
lst1.append("L")

lst2.append("U")
lst2 += ["L" for i in range(tx-sx+1)]
lst2 += ["D" for i in range(ty-sy+1)]
lst2.append("R")

lst3 += ["R" for i in range(tx-sx)]
lst3 += ["U" for i in range(ty-sy)]

lst4 += ["L" for i in range(tx-sx)]
lst4 += ["D" for i in range(ty-sy)]

lst = lst1+lst2+lst3+lst4

print("".join(lst))

Submission status: Accepted

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

x = tx-sx
y = ty-sy

s = ['U']*y + ['R']*(x+1) + ['D']*(y+1) + ['L']*(x+1) + ['U'] + ['R']*x + ['U']*(y+1) + ['L']*(x+1) + ['D']*(y+1) + ['R']
print(''.join(s))

Submission status: Accepted

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

Submission status: Accepted

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

#1回目行き
for i in range(tx-sx):
    route += "R"

for i in range(ty-sy):
    route += "U"

#1回目戻り
for i in range(abs(sx-tx)):
    route += "L"

for i in range(abs(sy-ty)):
    route += "D"

#2回め行き
route += "D"
for i in range((tx+1)-sx):
    route += "R"

for i in range(ty-(sy-1)):
    route += "U"

route += "L"

#2回め戻り
route += "U"
for i in range(abs((sx-1)-tx)):
    route += "L"

for i in range(abs(sy-(ty+1))):
    route += "D"

route += "R"

print(route)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx , sy , tx , ty = map(int,input().split())
print("L",end="")
for i in range(ty-sy+1):
    print("U",end="")
for i in range(tx-sx+1):
    print("R",end="")
for i in range(ty-sy+1):
    print("D",end="")
for i in range(tx-sx):
    print("L",end="")
for i in range(ty-sy):
    print("U",end="")
for i in range(tx-sx+1):
    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")

Submission status: Accepted

Solution code:
def abc051_c():
  sx, sy, tx, ty = map(int, input().split())
  # ひとまずsの右上にtがある前提で経路作る
  path = ''
  # 1周目：左上方向に1ずつふくらむ
  path += 'R' * abs(tx - sx)
  path += 'U' * (abs(ty - sy) + 1)
  path += 'L' * (abs(tx - sx) + 1)
  path += 'D' * (abs(ty - sy) + 1)
  path += 'R'
  # 2周目：右下方向に1ずつふくらむ
  path += 'D'
  path += 'R' * (abs(tx - sx) + 1)
  path += 'U' * (abs(ty - sy) + 1)
  path += 'L' * (abs(tx - sx) + 1)
  path += 'D' * abs(ty - sy)
  # sとtの位置関係により座標反転
  if tx < sx:
    path.replace('R','X').replace('L','R').replace('X','L')
  if ty < sx:
    path.replace('U','Y').replace('D','U').replace('Y','D')
  print(path)

abc051_c()

Submission status: Accepted

Solution code:
if __name__ == '__main__':
	sx, sy, tx, ty = map(int, input().split())
	u1 = ty - sy
	r2 = tx - sx

	root = 'U' * u1 + 'R' * r2 + 'D' * u1 + 'L' * (r2+1)
	root2 = 'U' * (u1+1) + 'R' * (r2+1) + 'D' + 'R' + 'D' * (u1+1) + 'L' * (r2+1) + 'U'
	print(root + root2)

Submission status: Accepted

Solution code:
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()


def resolve():
    sx,sy,tx,ty=map(int,input().split())
    tate=ty-sy
    yoko=tx-sx

    for _ in range(tate):
        print('U',sep='',end='')
    for _ in range(yoko+1):
        print('R',sep='',end='')
    for _ in range(tate+1):
        print('D',sep='',end='')
    for _ in range(yoko+1):
        print('L',sep='',end='')
    for _ in range(1):
        print('U',sep='',end='')
    for _ in range(1):
        print('L',sep='',end='')
    for _ in range(tate+1):
        print('U',sep='',end='')
    for _ in range(yoko+1):
        print('R',sep='',end='')
    for _ in range(tate+1):
        print('D',sep='',end='')
    for _ in range(yoko):
        print('L',sep='',end='')
    print()




resolve()

Submission status: Accepted

Solution code:

import sys
import fractions

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

sx, sy, tx, ty = lr()

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

s=""

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

print(s)

Submission status: Accepted

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

if __name__ == '__main__':
  main()

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

Submission status: Accepted

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

first  = (c-a)*"R"+(d-b)*"U"
second = (c-a)*"L"+(d-b)*"D"
third  = "D"+(c-a+1)*"R"+(d-b+1)*"U"+"L" 
fourth = "U"+(c-a+1)*"L"+(d-b+1)*"D"+"R"

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

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
s=""
if tx!=sx and ty!=sy:
  #内回り計算
  s+="R"*x
  s+="U"*y
  s+="L"*x
  s+="D"*y
  #外回り
  s+="L"
  s+="U"*(y+1)
  s+="R"*(x+1)
  s+="D"
  s+="R"
  s+="D"*(y+1)
  s+="L"*(x+1)
  s+="U"
"""
elif tx==sx:
  s+="R"*x
  
  s+="D"+"L"*x+"U"
  
  s+="U"+"R"*x+"D"

  s+="R"
  s+="U"*2
  s+="L"*(x+2)
  s+="D"*2
  s+="R"
elif ty==sy:
  s+="U"*x
  s+="R"+"D"*x+"L"
  s+="L"+"U"*x+"R"
  s+="U"
  s+="R"*2
  s+="D"*(y+2)
  s+="L"*2
  s+="U"
"""
print(s)

Submission status: Accepted

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

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

print(r)

Submission status: Accepted

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

print("U"*(gy-sy)+"R"*(gx-sx)+"D"*(gy-sy)+"L"*(gx-sx)+"L"+"U"*(gy-sy+1)+"R"*(gx-sx+1)+"D"+"R"+"D"*(gy-sy+1)+"L"*(gx-sx+1)+"U")

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


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


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import math  # noqa
import bisect  # noqa
import queue  # noqa


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

    ans = []

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

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

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

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

    print(''.join(ans))

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    sx, sy, tx, ty = list(map(int, readline().split()))

    xdif = tx - sx
    ydif = ty - sy

    res = ""

    res += "U" * ydif
    res += "R" * xdif
    res += "D" * ydif
    res += "L" * xdif

    res += "L"
    res += "U" * (ydif + 1)
    res += "R" * (xdif + 1)
    res += "D"
    res += "R"
    res += "D" * (ydif + 1)
    res += "L" * (xdif + 1)
    res += "U"

    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

dx = (tx - sx)
dy = (ty - sy)
l1 = 'U' * dy + 'R' * dx
l2 = 'D' * dy + 'L' * dx
l3 = 'D' + 'R' * (dx + 1) + 'U' * (dy + 1) + 'L'
l4 = 'U' + 'L' * (dx + 1) + 'D' * (dy + 1) + 'R'

print(l1 + l2 + l3 + l4)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
string=""
directionx=""



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

if dx>=0:
    directionx="R"
    directionxr="L"
else:
    directionx="L"
    directionxr="R"


if dy>=0:
    directiony="U"
    directionyr="D"
else:
    directiony="D"
    directionyr="U"
    
for _ in range (dx):
    string=string+directionx
for _ in range (dy):
    string=string+directiony
for _ in range (dx):
    string=string+directionxr
for _ in range (dy):
    string=string+directionyr

string=string+directionyr
for _ in range (dx+1):
    string=string+directionx
for _ in range (dy+1):
    string=string+directiony
string=string+directionxr
string=string+directiony
for _ in range (dx+1):
    string=string+directionxr
for _ in range (dy+1):
    string=string+directionyr
string=string+directionx
    
print(string)

Submission status: Accepted

Solution code:
m1, m2, n1, n2 = map(int, input().split())
n = n1-m1
m = n2-m2
ans = ""
go = "U"*m+"R"*n
back = "D"*m+"L"*n
a1 = "LU"
a2 = "RDRD"
a3 = "LU"
print(go+back+a1+go+a2+back+a3)

Submission status: Accepted

Solution code:
x, y, X, Y = map(int, input().split())
L, R, U, D = "L", "R", "U", "D"
print("".join([R]*(X-x)+[U]*(Y-y)+[L]*(X-x)+[D]*(Y-y)+[D]+[R]*(X-x+1)+[U]*(Y-y+1)+[L, U]+[L]*(X-x+1)+[D]*(Y-y+1)+[R]))

Submission status: Accepted

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

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

    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

Submission status: Accepted

Solution code:
X = [int(e) for e in input().split()]
sx=X[0]
sy=X[1]
tx=X[2]
ty=X[3]
k=0
dy = ty - sy
dx = tx - sx
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())
ans = []
for _ in range(tx-sx):
    ans.append("R")
for _ in range(ty-sy):
    ans.append("U")
for _ in range(tx-sx):
    ans.append("L")
for _ in range(ty-sy):
    ans.append("D")
ans.append("D")
for _ in range(tx-sx+1):
    ans.append("R")
for _ in range(ty-sy+1):
    ans.append("U")
ans.append("L")
ans.append("U")
for _ in range(tx-sx+1):
    ans.append("L")
for _ in range(ty-sy+1):
    ans.append("D")
ans.append("R")
print("".join(ans))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

dx = tx-sx
dy = ty-sy


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

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int, input().split())
x=-sx
y=-sy
sx+=x
sy+=y
tx+=x
ty+=y
tx=abs(tx)
ty=abs(ty)
 
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(''.join(ans))

Submission status: Accepted

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

n = tx - sx
m = ty - sy

ans = 'R' * n + 'U' * m + 'L' * n + 'D' * m + 'L' + 'U' * (m+1) + 'R' * (n+1) + 'D' + 'R' + 'D' * (m+1) + 'L' * (n+1) + 'U'
print(ans)

Submission status: Accepted

Solution code:
import sys

a, b, c, d = map(int, sys.stdin.readline().split())

def main():
  dx = c - a
  dy = d - b
  res = 'U' * dy + 'R' * (dx + 1) + 'D' * (dy + 1) + 'L' * (dx + 1)
  res += 'UL'
  res += 'U' * (dy + 1) + 'R' * (dx + 1) + 'D' * (dy + 1) + 'L' * dx
  print(res)
   
if __name__ == '__main__':
  main()

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy

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

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

print(ans)

Submission status: Accepted

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

#直角にいく＆回り込むで２往復
dx,dy=tx-sx,ty-sy
one="R"*dx+"U"*dy
#print(one)
two=one.replace("R","L").replace("U","D")
#print(two)

three="D"+"R"*(dx+1)+"U"*(dy+1) +"L"
#print(three)
four=three
four=four.replace("D","d").replace("R","r").replace("U","u").replace("L","l")
four=four.replace("d","U").replace("r","L").replace("u","D").replace("l","R")
#print(four)
print(one+two+three+four)

Submission status: Accepted

Solution code:
u="U"
d="D"
l="L"
r="R"

sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
ans=""
ans+=r*dx
ans+=u*dy
ans+=l*dx
ans+=d*dy

ans+=d

ans+=r*dx+r
ans+=u*dy+u

ans+=l
ans+=u

ans+=l*dx+l
ans+=d*dy+d

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

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

    ans1 = ["R"]*tx + ["U"]*ty
    ans2 = ["L"]*tx + ["D"]*ty
    ans3 = ["D"]+["R"]*(tx+1)+["U"]*(ty+1)+["L"]
    ans4 = ["U"] + ["L"]*(tx+1)+["D"]*(ty+1)+["R"]
    print("".join(ans1+ans2+ans3+ans4))
resolve()

Submission status: Accepted

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

len_x = tx-sx
len_y = ty-sy

s = "U"*len_y+"R"*len_x+"D"*len_y+"L"*len_x
s += "L"
s += "U"*(len_y+1)
s += "R"*(len_x+1)
s += "D"
s += "R"
s += "D"*(len_y+1)
s += "L"*(len_x+1)
s += "U"

print(s)

Submission status: Accepted

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

Submission status: Accepted

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



print("".join(ans))