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
import math
import numpy as np
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

sx,sy,tx,ty = I()
a = ty-sy
b = tx-sx
ans1 = 'U'*a+'R'*b+'D'*a+'L'*(b+1)
ans2 = 'U'*(a+1)+'R'*(b+1)+'D'+'R'+'D'*(a+1)+'L'*(b+1)+'U'
print(ans1+ans2)

Submission status: Accepted

Solution code:
def solve():
    sx, sy, tx, ty = map(int, input().split())
    ans = ""
    ans += "R"*(tx-sx)+"U"*(ty-sy)
    ans += "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)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

ans = ""

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

TX -= SX
TY -= SY
SX = 0
SY = 0

res = ""

res += "U"*TY
res += "R"*TX
res += "D"*TY
res += "L"*(TX+1)
res += "U"*(TY+1)
res += "R"*(TX+1)
res += "D"
res += "R"
res += "D"*(TY+1)
res += "L"*(TX+1)
res += "U"

print(res)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c,d = inpl()
x = c-a
y = d-b
res = ''
res += 'U' * y + 'R' * x
res += 'D' * y + 'L' * x
res += 'L' + 'U' * (y+1) + 'R' * (x+1) + 'D'
res += 'R' + 'D' * (y+1) + 'L' * (x+1) + 'U'
print(res)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    sx,sy,tx,ty = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    ans=""
    tx-=sx;ty-=sy
    for _ in range(tx):
        ans+="R"
    for _ in range(ty):
        ans+="U"
    for _ in range(tx):
        ans+="L"
    for _ in range(ty):
        ans+="D"
    ans+="D"
    for _ in range(tx+1):
        ans+="R"
    for _ in range(ty+1):
        ans+="U"
    ans+="L"
    ans+="U"
    for _ in range(tx+1):
        ans+="L"
    for _ in range(ty+1):
        ans+="D"
    ans+="R"
    print(ans)






if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
# from collections import defaultdict, deque
# import math
# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 1000000007

def solve():
    sx, sy, tx, ty = getList()
    dx = tx - sx
    dy = ty - sy
    ans = []
    for i in range(dy):
        ans.append("U")
    for i in range(dx):
        ans.append("R")
    for i in range(dy):
        ans.append("D")
    for i in range(dx):
        ans.append("L")

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

    ans.append("R")
    for i in range(dy + 1):
        ans.append("D")
    for i in range(dx + 1):
        ans.append("L")
    ans.append("U")
    print("".join(ans))

def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    # main()
    solve()

Submission status: Accepted

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

th1 = "R"*(c-a)
th2 = "U"*(d-b)
th3 = "L"*(c-a)
th4 = "D"*(d-b)
th5 = "D"+"R"*(c-a+1)+"U"*(d-b+1)+"L"
th6 = "U"+"L"*(c-a+1)+"D"*(d-b+1)+"R"

ans=th1+th2+th3+th4+th5+th6
print(ans)

Submission status: Accepted

Solution code:
x1,y1,x2,y2=map(int,input().split())
ans=[]
for i in range(y2-y1):
  ans.append('U')
for i in range(x2-x1):
  ans.append('R')
for i in range(y2-y1):
  ans.append('D')
for i in range(x2-x1):
  ans.append('L')
ans.append('L')
for i in range(y2-y1+1):
  ans.append('U')
for i in range(x2-x1+1):
  ans.append('R')
ans.append('D')
ans.append('R')
for i in range(y2-y1+1):
  ans.append('D')
for i in range(x2-x1+1):
  ans.append('L')
ans.append('U')
print(''.join(ans))

Submission status: Accepted

Solution code:
A,B,C,D=map(int,input().split())
P='R'*(C-A)
P+='U'*(D-B)
P+='L'*(C-A)
P+='D'*(D-B+1)
P+='R'*(C-A+1)
P+='U'*(D-B+1)
P+='L'
P+='U'
P+='L'*(C-A+1)
P+='D'*(D-B+1)
print(P+'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
ans+="L"*x+"D"*y
x+=1
y+=1
ans+="L"+"U"*y+"R"*x+"D"
ans+="R"+"D"*y+"L"*x+"U"
print(ans)

Submission status: Accepted

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

# path 1
print(dy*"U" + dx*"R", end="")
# path 2
print(dy*"D" + dx*"L", end="")
# path 3
print("L" + (dy+1)*"U" + (dx+1)*"R" + "D", end="")
# path 4
print("R" + (dy+1)*"D" + (dx+1)*"L" + "U", end="")
print()

Submission status: Accepted

Solution code:
sx, sy, tx, ty, = [int(i) for i in input().split()]
x_diff = tx - sx
y_diff = ty - sy

output = ''
# 1周目
output += 'U'*y_diff
output += 'R'*x_diff
output += 'D'*y_diff
output += 'L'*x_diff

#2周目
output += 'L'
output += 'U'*(y_diff+1)
output += 'R'*(x_diff+1)
output += 'D'
output += 'R'
output += 'D'*(y_diff+1)
output += 'L'*(x_diff+1)
output += 'U'

print(output)

Submission status: Accepted

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

dx = abs(tx - sx)
dy = abs(ty - sy)

s = ['U'] * dy + ['R'] * dx + ['U'] + ['L'] * (dx+1) + ['D'] * (dy+1) + ['R'] + ['R'] * dx + ['U'] * dy + ['R'] + ['D'] * (dy+1) + ['L'] * (dx + 1) + ['U']

print("".join(s))

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
s_x,s_y,t_x,t_y=map(int,input().split())

ans=''

hor = t_x - s_x
ver = t_y - s_y

ans='U'*ver + 'R'*hor + 'D'*ver + 'L'*hor + 'L' + 'U'*(ver+1) +'R'*(hor+1)+'D'+'R' + 'D'*(ver+1)+'L'*(hor+1)+'U' 

print(ans)

Submission status: Accepted

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

w = tx - sx
h = ty - sy

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

Submission status: Accepted

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

dist_x = tx - sx
dist_y = ty - sy

res = "R" * dist_x + "U" * dist_y + "L" * dist_x + "D" * dist_y + "D" + "R" * (dist_x + 1) + "U" * (dist_y + 1) + "L" + "U" + "L" * (dist_x + 1) + "D" * (dist_y + 1) + "R"
print(res)

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) + 'LU' + 'L'*(X+1) + 'D'*(Y+1) + 'R')

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+1): print("L",end="")
for _ in range(ty-sy+1): print("U",end="")
for _ in range(tx-sx+1): print("R",end="")
print("DR",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:
sx,sy,tx,ty=map(int,input().split())
dx = tx - sx
dy = ty - sy
direction1 = 'U'*dy + 'R'*dx 
direction2 = 'D'*dy + 'L'*dx
direction3 = 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D'
direction4 = 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'
print(direction1+direction2+direction3+direction4)

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int,input().split())
#print(sx,sy,tx,ty)
diffx = tx-sx
diffy = ty-sy
#print(diffx,diffy)
st = ''
for i in range(2):
    if i == 0:
        st = st + 'U'*diffy+'R'*diffx+'D'*diffy+'L'*diffx
    if i ==1:
        st = st + 'L'+'U'*(diffy+1)+'R'*(diffx+1)+'D'+'R'+'D'*(diffy+1)+'L'*(diffx+1)+'U'
print(st)

Submission status: Accepted

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

# ーをかけると文字が消える
cmd1 = 'R' * dx + 'U' * dy
cmd2 = 'L' * dx + 'D' * dy
cmd3 = 'D' + 'R' * (dx+1) + 'U' * (dy+1) + 'L'
cmd4 = 'U' + 'L' * (dx+1) + 'D' * (dy+1) + 'R'
ans = cmd1 + cmd2 + cmd3 + cmd4
print(ans)

Submission status: Accepted

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

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

print(A)

Submission status: Accepted

Solution code:
import sys

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

    horiz = tx - sx
    vert = ty - sy

    first_move = "U"*vert + "R"*horiz + "D"*vert + "L"*horiz
    second_move_go = "L" + "U"*(vert+1) + "R"*(horiz+1) + "D"
    second_move_back = "R" + "D"*(vert+1)+ "L"*(horiz+1) + "U" 
    print(first_move + second_move_go + second_move_back)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def calculate(cx1, cy1, cx2, cy2):

    Up = 'U'
    Right = 'R'
    Left = 'L'
    Down = 'D'

    h = abs(cy2 - cy1)
    w = abs(cx2 - cx1)

    if cx2 > cx1:
        if cy2 < cy1:
            Down = 'U'
            Up = 'D'
    else:
        if cy2 > cy1:
            Left = 'R'
            Right = 'L'
        else:
            Left = 'R'
            Right = 'L'
            Down = 'U'
            Up = 'D'

    return h * Up + w * Right + h * Down + (w + 1) * Left + (h + 1) * Up + (w + 1) * Right + Down + Right + (
            h + 1) * Down + (w + 1) * Left + Up


cx1, cy1, cx2, cy2 = -2, -2, 1, 1
cx1, cy1, cx2, cy2 = map(int,input().split())

print(calculate(cx1, cy1, cx2, cy2))

Submission status: Accepted

Solution code:
x,y,u,v=map(int,input().split())

p=u-x
q=v-y

S="U"*q+"R"*p+"D"*q
S+="L"*(p+1)+"U"*(q+1)+"R"*(p+1)+"D"+"R"+"D"*(q+1)+"L"*(p+1)+"U"
print(S)

Submission status: Accepted

Solution code:
import copy

sx, sy, tx, ty = map(int, input().split())
p = [sx, sy]
g = []
b = []

for _ in range(1,tx - sx):
    g.append('R')
    b.append('L')
for _ in range(1,ty - sy):
    g.append('U')
    b.append('D')

b.reverse()

g1 = g
g1.insert(0,'R')
g1.append('U')
g2 = copy.deepcopy(g1)
g2.insert(0,'R')
g2.insert(0,'D')
g2.append('U')
g2.append('L')
b1 = b
b1.insert(0,'L')
b1.append('D')
b2 = copy.deepcopy(b1)
b2.insert(0,'L')
b2.insert(0,'U')
b2.append('D')
b2.append('R')

ans = []
ans.extend(g1)
ans.extend(b1)
ans.extend(g2)
ans.extend(b2)
ans = ''.join(ans)
print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
ans = []
ans += ["R"] * (tx - sx) + ["U"] * (ty - sy)
ans += ["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("".join(ans))

Submission status: Accepted

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

Takasa = Ty-Sy
Haba = Tx-Sx

Ito = []

for i in range (0, Takasa):
	Ito.append('U')

for i in range (0, Haba):
	Ito.append('R')

for i in range (0, Takasa):
	Ito.append('D')

for i in range (0, Haba+1):
	Ito.append('L')

for i in range (0, Takasa+1):
	Ito.append('U')

for i in range (0, Haba+1):
	Ito.append('R')

Ito.append('DR')

for i in range (0, Takasa+1):
	Ito.append('D')

for i in range (0, Haba+1):
	Ito.append('L')

Ito.append('U')

print(*Ito, sep='')

Submission status: Accepted

Solution code:
sx, sy, tx, ty = list(map(int, input().split()))
dy = abs(ty-sy)
dx = abs(tx-sx)
# 1巡目
ans = ''
ans += 'U'*(dy)
ans += 'R'*(dx)
ans += 'D'*(dy)
ans += 'L'*(dx)
# 2巡目
ans += 'L'
ans += 'U'*(dy+1)
ans += 'R'*(dx+1)
ans += 'D'
ans += 'R'
ans += 'D'*(dy+1)
ans += 'L'*(dx+1)
ans += 'U'

print(ans)

Submission status: Accepted

Solution code:
def solve():
    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'
    return ans

print(solve())

Submission status: Accepted

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

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

print(res)

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(abs(sy-ty)):
    ans.append("D")
for i in range(abs(sx-tx)):
    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(abs(sy-ty)+1):
    ans.append("D")
for i in range(abs(sx-tx)+1):
    ans.append("L")
ans.append("U")

print("".join(ans))

Submission status: Accepted

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

def get_path(moves):
  path = ''
  for y, x in moves:
    if y > 0:
      path += 'U' * y
    else:
      path += 'D' * -y
    if x > 0:
      path += 'R' * x
    else:
      path += 'L' * -x
  return path

first_moves = []
foward_y = ty - sy
foward_x = tx - sx
first_moves.append((foward_y, foward_x))
first_moves.append((-foward_y, -foward_x))

second_moves = []
foward_y = (ty + 1) - sy
foward_x = tx - (sx - 1)
second_moves.append((0, -1))
second_moves.append((foward_y, foward_x))
second_moves.append((-1, 0))
second_moves.append((0, 1))
second_moves.append((-foward_y, -foward_x))
second_moves.append((1, 0))

print(get_path(first_moves + second_moves))

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
sx,sy,tx,ty=map(int,input().split())
h=ty-sy
w=tx-sx

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

Submission status: Accepted

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

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:
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:
sx,sy,tx,ty = map(int, input().split())
y1=ty-sy
x1=tx-sx
a = "U"*y1+"R"*x1+"D"*y1+"L"*x1+"L"+"U"*(y1+1)+"R"*(x1+1)+"D"+"R"+"D"*(y1+1)+"L"*(x1+1)+"U"
print(a)

Submission status: Accepted

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



if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    sx,sy,tx,ty = map(int,ipt().split())
    dx = tx-sx
    dy = ty-sy
    print("U"*dy+"R"*dx+"D"*dy+"L"*dx+"L"+"U"*(dy+1)+"R"*(dx+1)+"D"+"R"+"D"*(dy+1)+"L"*(dx+1)+"U")
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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) + "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:
st = list(map(int,input().split()))
x = st[2] - st[0]
y = st[3] - st[1]
l1 = 'U'*y + 'R'*x
l2 = 'D'*y + 'L'*x
l3 = 'L' + 'U'*(y+1) + 'R'*(x+1) + 'D'
l4 = 'R' + 'D'*(y+1) + 'L'*(x+1) + 'U'
print(l1+l2+l3+l4)

Submission status: Accepted

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

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


# ===CODE===


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

    ans = []

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

    ans.extend(["L"])

    ans.extend(["U"] * (ty - sy + 1))
    ans.extend((["R"] * (tx - sx + 1)))

    ans.extend(["DR"])

    ans.extend(["D"] * ((ty - sy + 1)))
    ans.extend((["L"] * (tx - sx + 1)))

    ans.extend(["U"])

    print(*ans, sep="")


if __name__ == '__main__':
    main()

Submission status: Accepted

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

x = tx - sx
y = ty - sy

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

Submission status: Accepted

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


def inverse(line :str):
    ret = ""
    for c in line:
        if c == "U":
            ret += "D"
        elif c == "D":
            ret += "U"
        elif c == "R":
            ret += "L"
        else:
            ret += "R"
    
    return ret

# 1st loop
str1out = ""
for dx in range(tx - sx):
    str1out += "R"

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

str1in = inverse(str1out)

# 2nd loop
str2out = "DR" + str1out + "UL"
str2in = "UL" + str1in + "DR"
print(str1out + str1in + str2out + str2in)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, D = map(int,input().split())
tx = C - A
ty = D - B

def Ans(U,D,R,L,tx,ty):#U,R,D,L
    tx = abs(tx)
    ty = abs(ty)
    ans = U*ty+R*tx+D*ty+L*tx #1巡目
    ans += L+U*(ty+1)+R*(tx+1)+D+R+D*(ty+1)+L*(tx+1)+U
    return ans

if tx >= 0 and ty >= 0:
    print(Ans("U","D","R","L",tx,ty))
elif tx < 0 and ty < 0:
    print(Ans("D","U","L","R",tx,ty))
elif tx >= 0 and ty <0:
    print(Ans("D","U","R","L",tx,ty))
else:
    print(Ans("U","D","L","R",tx,ty))

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx-sx, ty-sy
S = '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(S)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,x,y=map(int,input().split())
ans="UD"[b>y]*abs(b-y)+"LR"[a<x]*abs(a-x)
ans+="UD"[b<y]*abs(b-y)+"LR"[a>x]*abs(a-x)
ans+="LR"[a>x]+"UD"[b>y]*(abs(b-y)+1)+"LR"[a<x]*(abs(a-x)+1)+"UD"[b<y]
ans+="LR"[a<x]+"UD"[b<y]*(abs(b-y)+1)+"LR"[a>x]*(abs(a-x)+1)+"UD"[b>y]
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+1)
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:
def main():
    sx, sy, tx, ty = list(map(int, input().split(' ')))
    assert sx < tx and sy < ty
    # s -> t
    ans = 'R' * (tx - sx) + 'U' * (ty - sy)
    # t -> s
    ans += 'L' * (tx - sx) + 'D' * (ty - sy)
    # s -> t
    ans += 'D' + 'R' * (tx - sx + 1) + 'U' * (ty - sy + 1) + 'L'
    # t -> s
    ans += 'U' + 'L' * (tx - sx + 1) + 'D' * (ty - sy + 1) + 'R'
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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:
#!/usr/bin/env python3
sx, sy, tx, ty = map(int, input().split())
x, y = tx - sx, ty - sy
print("R"*x + "U"*-~y + "L"*-~x + "D"*-~y + "R" + "U"*y + "R"*-~x + "D"*-~y + "L"*-~x + "U")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Jun  1 13:02:30 2020

@author: NEC-PCuser
"""

SX, SY, TX, TY = map(int, input().split())

ans = ""

if TX - SX > 0 and TY - SY > 0:
    first = "R"
    second = "U"
    third = "L"
    forth = "D"
elif TX - SX < 0 and TY - SY > 0:
    first = "L"
    second = "U"
    third = "R"
    forth = "D"
elif TX - SX < 0 and TY - SY < 0:
    first = "L"
    second = "D"
    third = "R"
    forth = "U"
elif TX - SX > 0 and TY - SY < 0:
    first = "R"
    second = "D"
    third = "L"
    forth = "U"

for i in range (TX - SX):
    ans += first
for i in range (TY - SY):
    ans += second
for i in range (TX - SX):
    ans += third
for i in range (TY - SY):
    ans += forth
ans += forth
for i in range (TX - SX + 1):
    ans += first
for i in range (TY - SY + 1):
    ans += second
ans += third
ans += second
for i in range (TX - SX + 1):
    ans += third
for i in range (TY - SY + 1):
    ans += forth
ans += first

print(ans)