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

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

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

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

main()

Submission status: Accepted

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

#   0
#3     1
#   2
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())
xtmp = abs(sx - tx)
ytmp = abs(sy - ty)
ans = 'U' * ytmp
ans += 'R' * xtmp
tmp1 = ans
tmp1 = tmp1.replace('R', 'L')
tmp1 = tmp1.replace('U', 'D')
tmp2 = 'LU' + ans + 'RD'
tmp3 = 'RD' + tmp1 + 'LU'
print(ans + tmp1 + tmp2 + tmp3)

Submission status: Accepted

Solution code:
xs, ys, xt, yt = map(int, input().split())

# root1
for _ in range(xs, xt):
    print('R', end='')
for _ in range(ys, yt):
    print('U', end='')

# root2
for _ in range(xt, xs, -1):
    print('L', end='')
for _ in range(yt, ys, -1):
    print('D', end='')

# root3
print('D', end='')
for _ in range(xs, xt+1):
    print('R', end='')
for _ in range(ys-1, yt):
    print('U', end='')
print('L', end='')

# root4
print('U', end='')
for _ in range(xt, xs-1, -1):
    print('L', end='')
for _ in range(yt+1, ys, -1):
    print('D', end='')
print('R', end='')

print('')

Submission status: Accepted

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

dif_x = tx - sx
dif_y = ty - sy

ans = 'U' * dif_y + 'R' * dif_x + 'D' * dif_y + 'L' * (dif_x + 1)\
     + 'U' * (dif_y + 1) + 'R' * (dif_x + 1) + 'D' + 'R' + 'D' * (dif_y + 1) + 'L' * (dif_x + 1) + 'U'

print(ans)

Submission status: Accepted

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

s =''

distx = tx - sx #x方向の距離
disty = ty - sy #y方向の距離

act = ['U','D','L','R']#[上、下、左、右]

#1
s += act[3]*distx + act[0]*disty

#2
s += act[2]*distx + act[1]*disty

#3
s += act[1] + act[3]*(distx + 1) + act[0]*(disty+1)+act[2]

#4
s += act[0] + act[2]*(distx + 1) + act[1]*(disty+1)+act[3]

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

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

ans=''
ans+=''.join(['U']*(d-b))
ans+=''.join(['R']*(c-a))
ans+=''.join(['D']*(d-b))
ans+=''.join(['L']*(c-a+1))
ans+=''.join(['U']*(d-b+1))
ans+=''.join(['R']*(c-a+1))
ans+='DR'
ans+=''.join(['D']*(d-b+1))
ans+=''.join(['L']*(c-a+1))
ans+='U'
print(ans)

Submission status: Accepted

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

ans = ""

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

print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split(" "))
result = ""
# first s -> t
result += "U" * abs(ty - sy)
result += "R" * abs(tx - sx)
# first t -> s
result += "D" * abs(sy - ty)
result += "L" * abs(sx - tx)
# second s -> t
result += "L" + "U" * (1 + abs(ty - sy))
result += "R" * (1 + abs(tx - sx))
result += "D"
# second t -> s
result += "R" + "D" * (1 + abs(sy - ty))
result += "L" * (1 + abs(sx - tx))
result += "U"
print(result)

Submission status: Accepted

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

x_dif = tx - sx
y_dif = ty - sy

first_loop = ('U' * y_dif) + ('R' * x_dif) + 'D' * y_dif + 'L' * x_dif
#second_loop
second_loop_1 = 'D' + 'R' * (x_dif + 1) + 'U' * (y_dif + 1) + 'L'
second_loop_2 = 'U' + 'L' * (x_dif + 1) + 'D' * (y_dif + 1) + 'R'
print(first_loop + second_loop_1 + second_loop_2)

Submission status: Accepted

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

route1 = 'U' * y + 'R' * x
route2 = 'D' * y + 'L' * x
route3 = 'L' + 'U' * (y + 1) + 'R' * (x + 1) + 'D'
route4 = 'R' + 'D' * (y + 1) + 'L' * (x + 1) + 'U'

print(route1 + route2 + route3 + route4)

Submission status: Accepted

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

length = ty - sy
width = tx - sx
u = "U"
l = "L"
r = "R"
d = "D"
ans = ''
ans += r*width + u*length
ans += l*width + d*length
ans += d + r*(width+1) + u*(length+1) + l
ans += u + l*(width+1) + d*(length+1) + r
print(ans)

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy

r1 = 'U' * dy + 'R' * dx
r2 = 'D' * dy + 'L' * dx
r3 = 'L' + 'U' * (dy + 1) + 'R' * (dx + 1)+'D'
r4 = 'R'+'D'*(dy+1)+'L'*(dx+1)+'U'
ans = r1 + r2 + r3 + r4
print(ans)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
for i in range(y):
    print('U',end='')
for i in range(x):
    print('R',end='')
for i in range(y):
    print('D',end='')
for i in range(x):
    print('L',end='')
print('L',end='')
for i in range(y+1):
    print('U',end='')
for i in range(x+1):
    print('R',end='')
print('D',end='')
print('R',end='')
for i in range(y+1):
    print('D',end='')
for i in range(x+1):
    print('L',end='')
print('U')

Submission status: Accepted

Solution code:
#C-Back and Forth
sx,sy,tx,ty=map(int,input().split( ))
x=tx-sx
y=ty-sy
r1="U"*y+"R"*x
r2="R"+"D"*2+"L"*(x-1)+"D"*(y-1)+"L"*2+"U"
r3="R"+"U"*(y-1)+"R"*(x-1)+"U"
r4="U"+"L"*(x+1)+"D"*(y+1)+"R"
print(r1+r2+r3+r4)

Submission status: Accepted

Solution code:

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


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

ans += 'R' * x
ans += 'U' * y
ans += 'L' * x
ans += 'D' * (y+1)
ans += 'R' * (x+1)
ans += 'U' * (y+1)
ans += 'L'
ans += 'U'
ans += 'L' * (x+1)
ans += 'D' * (y+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()]
ans = ""
ans += (ty-sy)*"U"
ans += (tx-sx)*"R"
ans2 = ans.replace("R","tmp").replace("L","R").replace("tmp","L")
ans2 = ans2.replace("U","tmp").replace("D","U").replace("tmp","D")
ans = ans + ans2 +"LU"+ans+"RD" + "RD" + ans2 + "LU"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

tx-=sx
ty-=sy

ans=""

for i in range(tx):
  ans+="R"
for i in range(ty):
  ans+="U"
for i in range(tx):
  ans+="L"
for i in range(ty):
  ans+="D"

ans+="D"
for i in range(tx):
  ans+="R"
ans+="R"

ans+="U"
for i in range(ty):
  ans+="U"
ans+="L"

ans+="U"
for i in range(tx):
  ans+="L"
ans+="L"

ans+="D"
for i in range(ty):
  ans+="D"
ans+="R"

print(ans)

Submission status: Accepted

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

r1=["R"]*(tx-sx)

r1.append("U"*(ty-sy))

r1.append("L"*(tx - sx))

r1.append("D"*(ty - sy))

r1.append("D")

r1.append("R"*(tx-sx+1))

r1.append("U"*(ty-sy+1))

r1.append("LU")

r1.append("L"*(tx-sx+1))

r1.append("D"*(ty-sy+1))

r1.append("R")

print("".join(r1))

Submission status: Accepted

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

r1=["R"]

for i in range(tx-sx-1):
    r1.append("R")

for i in range(ty-sy):
    r1.append("U")

for i in range(tx - sx):
    r1.append("L")

for i in range(ty - sy):
    r1.append("D")

r1.append("D")

for i in range(tx-sx+1):
    r1.append("R")

for i in range(ty-sy+1):
    r1.append("U")

r1.append("LU")

for i in range(tx-sx+1):
    r1.append("L")

for i in range(ty-sy+1):
    r1.append("D")

r1.append("R")

print("".join(r1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import deque
sx,sy,tx,ty=map(int,input().split())
# sx,sy,tx,ty=-2,-2,1,1
result=deque()
A=B=C=D=0

#右に移動
for _ in range(sx,tx):
  result.append("R")
  A+=1

#上に移動
if sy!=ty:
  for _ in range(sy,ty):
    result.append("U")
    B+=1
#真横の点を指定されたとき
# else:
#   result.append("U")
#   B+=1

#左に1個移動して、上に移動した分-1だけ下にくだっていく
result.append("L")
for _ in range(B-1):
  result.append("D")
  C+=1

#右に移動した分-1だけ左に移動する
for _ in range(A-1):
  result.append("L")
  D+=1

#下に移動することでスタート地点に戻ってくる
result.append("D")

#下に１個移動し、A+1だけ右に移動
result.append("D")
for _ in range(A+1):
  result.append("R")

#B+1だけ上に移動
for _ in range(B+1):
  result.append("U")

#ゴールを通っててさらに上に
result.append("L")
result.append("U")

#左に2個移動して、Cだけ下がる
result.append("L")
result.append("L")
for _ in range(C):
  result.append("D")

#左にＤだけ移動
for _ in range(D):
  result.append("L")

#仕上げ
result.append("D")
result.append("D")
result.append("R")

print(*result,sep="")

Submission status: Accepted

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

invert = lambda T:(''.join(map(lambda x:dict([('R','L'),('L','R'),('U','D'),('D','U')])[x],list(T))))[::-1]
dist = lambda a,b:abs(a-b)
O = ""

O +=        "L" +  "U"*dist(sy  ,ty+1) + "R"*dist(sx-1,tx  )        + "D"
O += invert("U" +  "U"*dist(sy+1,ty  ) + "R"*dist(sx  ,tx-1)        + "R")
O +=        "R" + ("U"*dist(sy  ,ty-1) + "R"*dist(sx+1,tx  ))[::-1] + "U"
O += invert("D" + ("U"*dist(sy-1,ty  ) + "R"*dist(sx  ,tx+1))[::-1] + "L")

print(O)

Submission status: Accepted

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

def invert(T):
    d = dict([('R','L'),('L','R'),('U','D'),('D','U')])
    return (''.join(map(lambda x:d[x],list(T))))[::-1]

dist = lambda a,b:abs(a-b)
O = ""

O +=        "L" +  "U"*dist(sy  ,ty+1) + "R"*dist(sx-1,tx  )        + "D"
O += invert("U" +  "U"*dist(sy+1,ty  ) + "R"*dist(sx  ,tx-1)        + "R")
O +=        "R" + ("U"*dist(sy  ,ty-1) + "R"*dist(sx+1,tx  ))[::-1] + "U"
O += invert("D" + ("U"*dist(sy-1,ty  ) + "R"*dist(sx  ,tx+1))[::-1] + "L")

print(O)

Submission status: Accepted

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

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

# イルカの初めの位置を原点に移動，目標地点は第一象限固定
a = tx - sx
b = ty - sy

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=list(map(int, input().split()));x,y=a[2]-a[0],a[3]-a[1];r,u=x<0,y<0;x,y=abs(x),abs(y);v,h=["U","D"],["R","L"];print(v[u]*y+h[r]*x+v[u^1]*y+h[r^1]*(x+1)+v[u]*(y+1)+h[r]*(x+1)+v[u^1]+h[r]+v[u^1]*(y+1)+h[r^1]*(x+1)+v[u])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx,sy,X,Y = map(int,input().split())

ans = ""
ans += "U"*(Y-sy)
ans += "R"*(X-sx)
ans += "D"*(Y-sy)
ans += "L"*(X-sx)

ans += "L"+"U"*(Y-sy+1)
ans += "R"*(X-sx+1)+"D"
ans += "R" + "D"*(Y-sy+1)
ans += "L"*(X-sx+1)+"U"

print(ans)

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int, input().split())
    
UD_dic={"U":ty-sy, "D":-(ty-sy)}
RL_dic={"R":tx-sx, "L":-(tx-sx)}

ans=""

ans+=max(UD_dic)*max(UD_dic.values())+max(RL_dic)*max(RL_dic.values())
ans+=min(UD_dic)*abs(min(UD_dic.values()))+min(RL_dic)*abs(min(RL_dic.values()))

ans+=min(RL_dic)+max(UD_dic)*(max(UD_dic.values())+1)+max(RL_dic)*(max(RL_dic.values())+1)+min(UD_dic)
ans+=max(RL_dic)+min(UD_dic)*abs(min(UD_dic.values())-1)+min(RL_dic)*abs(min(RL_dic.values())-1)+max(UD_dic)

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

sx,sy,tx,ty = inpl()
ans = ''
ans += 'U' * (ty-sy) + 'R' * (tx-sx)
ans += '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:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    sx,sy,tx,ty=map(int,input().split())
    x,y=tx-sx,ty-sy
    ans=''
    # 1往復目
    ans=ans+'R'*x+'U'*y+'L'*x+'D'*y
    # 2往復目
    ans=ans+'D'+'R'*(x+1)+'U'*(y+1)+'L'+'U'+'L'*(x+1)+'D'*(y+1)+'R'
    print(ans)
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

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

dy = ty-sy
dx = tx-sx

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

cx = gx - sx
cy = gy - sy

dx = abs(gx - sx)
dy = abs(gy - sy)

if cx >= 0 and cy >= 0:
  ans = 'U'*dy+'R'*dx+'D'*dy+'L'*dx
  ans += 'LU'+'U'*dy+'R'*dx+'RD'
  ans += 'RD'+'D'*dy+'L'*dx+'LU'
elif cx < 0 and cy >= 0:
  ans = 'U'*dy+'L'*dx+'D'*dy+'R'*dx
  ans += 'RU'+'U'*dy+'L'*dx+'LD'
  ans += 'LD'+'D'*dy+'R'*dx+'RU'
elif cx >= 0 and cy < 0:
  ans = 'D'*dy+'R'*dx+'U'*dy+'L'*dx
  ans += 'LD'+'D'*dy+'R'*dx+'RU'
  ans += 'RU'+'U'*dy+'L'*dx+'LD'
else:
  ans = 'D'*dy+'L'*dx+'U'*dy+'R'*dx
  ans += 'RD'+'D'*dy+'L'*dx+'LU'
  ans += 'LU'+'U'*dy+'R'*dx+'RD'
print(ans)

Submission status: Accepted

Solution code:
x, y, X, Y = map(int, input().split())
ans = ''
kyori_x = X - x
kyori_y = Y - y
ans += 'R' * kyori_x + 'U' * kyori_y
ans += 'L' * kyori_x + 'D' * kyori_y
ans += 'L' + 'U' * (kyori_y + 1) + 'R' * (kyori_x + 1) + 'D'
ans += 'R' + 'D' * (kyori_y + 1) + 'L' * (kyori_x + 1) + 'U'
print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
X, Y, U, D, L, R = tx - sx, ty - sy, "U", "D", "L", "R"
XX, YY = X+1, Y+1

print(D+R*XX+U*YY+L*XX+D*Y+R*X+U*YY+L*XX+D*YY+R)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

x = gx-sx
y = gy-sy

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

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

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

Submission status: Accepted

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

ans = ''
dx = tx - sx
dy = ty - sy
ans += 'R' * dx
ans += 'U' * dy
ans += 'L' * dx
ans += 'D' * dy
ans += 'D'
ans += 'R' * (dx + 1)
ans += 'U' * (dy + 1)
ans += 'LU'
ans += 'L' * (dx + 1)
ans += 'D' * (dy + 1)
ans += 'R'
print(ans)

Submission status: Accepted

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

def p(s, num):
    print(s*num, end="")

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

    w, h = tx-sx, ty-sy

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce




INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


sx, sy, tx, ty = LI()

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'


print(way1 + way2 + way3 + way4)

Submission status: Accepted

Solution code:
data = [int(i) for i in input().split()]

x = data[2] - data[0] 
y = data[3] - data[1]

print("R"*x+"U"*y+"L"*x+"D"*y+"DR"+"R"*x+"U"*y+"ULUL"+"L"*x+"D"*y+"DR")

Submission status: Accepted

Solution code:
def move(x, y, direction):
    global ans, nx, ny
    if direction in ['U', 'D']:
        ans += direction * abs(ny - y)
    if direction in ['L', 'R']:
        ans += direction * abs(nx - x)
    nx, ny = x, y


sx, sy, tx, ty = map(int, input().split())
ans = ''
nx, ny = sx, sy

move(sx, ty, 'U')
move(tx, ty, 'R')

move(tx, sy, 'D')
move(sx, sy, 'L')

move(sx-1, sy, 'L')
move(sx-1, ty+1, 'U')
move(tx, ty+1, 'R')
move(tx, ty, 'D')

move(tx+1, ty, 'R')
move(tx+1, sy-1, 'D')
move(sx, sy-1, 'L')
move(sx, sy, 'U')

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int,input().split())
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'
print(way1+way2+way3+way4)

Submission status: Accepted

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

W,H=[c-a,d-b]

print('R'*W + 'U'*H, end='')
print('L'*W + 'D'*H, end='')
print('D' + 'R'*(W+1) + 'U'*(H+1) + 'L', end='')
print('U' + 'L'*(W+1) + 'D'*(H+1) + 'R', end='')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

SX, SY, TX, TY = map(int, stdin.readline().rstrip().split())


# S->T
# とりあえず上
print('U' * (TY - SY), end='')
print('R' * (TX - SX), end='')

# T->S
print('D' * (TY - SY), end='')
print('L' * (TX - SX), end='')

# S->T 2回目
# 左へ大回り
print('L', end='')
print('U' * (TY - SY + 1), end='')
print('R' * (TX - SX + 1), end='')
print('D', end='')

# T->S 2回目
# 右へ大回り
print('R', end='')
print('D' * (TY - SY + 1), end='')
print('L' * (TX - SX + 1), end='')
print('U')

Submission status: Accepted

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

ans = []

X = tx - sx
Y = ty - sy

for i in range(X):
    ans.append('R')
for i in range(Y):
    ans.append('U')
for i in range(X):
    ans.append('L')
for i in range(Y):
    ans.append('D')

ans.append('D')
for i in range(X + 1):
    ans.append('R')
for i in range(Y + 1):
    ans.append('U')
ans.append('L')
ans.append('U')
for i in range(X + 1):
    ans.append('L')
for i in range(Y + 1):
    ans.append('D')
ans.append('R')


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

Submission status: Accepted

Solution code:
#coding: utf-8

n = list(map(int, input().split()))
sx = n[0]
sy = n[1]
tx = n[2]
ty = n[3]
x = tx - sx
y = ty - sy

if x >= 0 and y >= 0:
    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")
elif x < 0 and y >= 0:
    print("L" * x + "U" * y + "R" * x + "D" * y + "D" + "L" * (x + 1) + "U" * (y + 1) + "R" + "U" + "R" * (x + 1) + "D" * (y + 1) + "L")
elif x >= 0 and y < 0:
    print("R" * x + "D" * y + "L" * x + "U" * y + "U" + "R" * (x + 1) + "D" * (y + 1) + "L" + "D" + "L" * (x + 1) + "U" * (y + 1) + "R")
else:
    print("L" * x + "D" * y + "R" * x + "U" * y + "U" + "L" * (x + 1) + "D" * (y + 1) + "R" + "D" + "R" * (x + 1) + "U" * (y + 1) + "L")

Submission status: Accepted

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

p1 = dx*"R"+dy*"U"
p2 = dx*"L"+dy*"D"
p3 = "D"+(1+dx)*"R"+(1+dy)*"U"+"L"
p4 = "U"+(1+dx)*"L"+(1+dy)*"D"+"R"

print(p1+p2+p3+p4)

Submission status: Accepted

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

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

Submission status: Accepted

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

ue = ty - sy
migi = tx - sx

print('U'*ue+'R'*migi+'D'*ue+'L'*(migi+1)+'U'*(ue+1)+'R'*(migi+1)+'D'+'R'+'D'*(ue+1)+'L'*(migi+1)+'U')

Submission status: Accepted

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

x_shift = tx - sx
y_shift = ty - sy
ans = ""
#1回目sy→ty
if y_shift > 0:
  for i in range(y_shift):
    ans += "U"
else:
  y = abs(y_shift)
  for i in range(y):
    ans += "D"
#sx→tx
if x_shift > 0:
  for i in range(x_shift):
    ans += "R"
else:
  x = abs(x_shift)
  for i in range(x):
    ans += "L"
#ty→sy
if y_shift > 0:
  for i in range(y_shift):
    ans += "D"
else:
  y = abs(y_shift)
  for i in range(y):
    ans += "U"
#tx→sx
if x_shift > 0:
  for i in range(x_shift + 1):
    ans += "L"
else:
  x = abs(x_shift)
  for i in range(x + 1):
    ans += "R"
#2回目sy→ty
if y_shift > 0:
  for i in range(y_shift + 1):
    ans += "U"
else:
  y = abs(y_shift)
  for i in range(y + 1):
    ans += "D"
#sx→tx
if x_shift > 0:
  for i in range(x_shift + 1):
    ans += "R"
else:
  x = abs(x_shift)
  for i in range(x + 1):
    ans += "L"
if y_shift > 0:
  ans += "D"
else:
  ans += "U"
if x_shift > 0:
  ans += "R"
else:
  ans += "L"
#ty→sy
if y_shift > 0:
  for i in range(y_shift + 1):
    ans += "D"
else:
  y = abs(y_shift)
  for i in range(y + 1):
    ans += "U"
#tx→sx
if x_shift > 0:
  for i in range(x_shift + 1):
    ans += "L"
else:
  x = abs(x_shift)
  for i in range(x + 1):
    ans += "R"
if y_shift > 0:
  ans += "U"
else:
  ans += "D"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split())
lia=[]
lib=[]
lia2=[]
lib2=[]

lia+='R'*(c-a)
lia+='U'*(d-b)
lia2+='D'
lia2+='R'*(c-a+1)
lia2+='U'*(d-b+1)
lia2+='L'

lib+='L'*(c-a)
lib+='D'*(d-b)
lib2+='U'
lib2+='L'*(c-a+1)
lib2+='D'*(d-b+1)
lib2+='R'
li=lia+lib+lia2+lib2
print(''.join(li))

Submission status: Accepted

Solution code:
def main():
    sx,sy,tx,ty = map(int,input().split())
    path =''
    ly,lx = abs(ty-sy),abs(tx-sx)
    #s->t:上から出て左から入る
    path += 'U' * ly
    path += 'R' * lx
    #t->s:下から出て右から入る
    path += 'D' * ly
    path += 'L' * lx
    #s->t:左から出て上から入る
    path += 'L' + 'U' * (ly+1)
    path += 'R' * (lx+1) + 'D'
    #t->s:右から出て下から入る
    path += 'R' +'D'*(ly+1)
    path += 'L'*(lx+1) +'U'
    print(path)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b,c,d = [int(x) for x in input().split()]
h,w = d-b,c-a

def rep(t,c):
	for i in range(t):
		print(c,end='')
rep(1,'L')
rep(h+1,'U')
rep(w+1,'R')
rep(1,'D')
rep(1,'R')
rep(h+1,'D')
rep(w+1,'L')
rep(1,'U')

rep(h,'U')
rep(w,'R')
rep(h,'D')
rep(w,'L')

print()

Submission status: Accepted

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

nx=tx-sx
ny=ty-sy

root_1='U'*ny+'R'*nx
root_2='R'+'D'*(ny+1)+'L'*(nx+1)+'U'
root_3='R'*nx+'U'*ny
root_4='U'+'L'*(nx+1)+'D'*(ny+1)+'R'

print(root_1+root_2+root_3+root_4)