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:
# C - Back and Forth
def main():
    sx, sy, tx, ty = map(int, input().split())

    rx = tx - sx
    ry = ty - sy

    ans = []

    # path1
    for _ in range(ry):
        ans.append('U')
    for _ in range(rx):
        ans.append('R')

    # path2
    for _ in range(ry):
        ans.append('D')
    for _ in range(rx):
        ans.append('L')

    # path3
    ans.append('L')
    for _ in range(ry+1):
        ans.append('U')
    for _ in range(rx+1):
        ans.append('R')
    ans.append('D')
    
    # path4
    ans.append('R')
    for _ in range(ry+1):
        ans.append('D')
    for _ in range(rx+1):
        ans.append('L')
    ans.append('U')
    
    print(''.join(ans))


if __name__ ==  "__main__":
    main()

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def main():

    inf = 10 ** 18
    mod = 10 ** 9 + 7

    sx, sy, tx, ty = lr()
    ans = []
    for i in range(tx-sx):
        ans.append('R')
    for i in range(ty-sy):
        ans.append('U')
    for i in range(tx-sx):
        ans.append('L')
    for i in range(ty-sy):
        ans.append('D')
    ans.append('D')
    for i in range(tx-sx+1):
        ans.append('R')
    for i in range(ty-sy+1):
        ans.append('U')
    ans.append('L')
    ans.append('U')
    for i in range(tx-sx+1):
        ans.append('L')
    for i in range(ty-sy+1):
        ans.append('D')
    ans.append('R')

    print(*ans, sep='')





    return

if __name__ == '__main__':
    main()

Submission status: Accepted

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

rx = tx - sx
ry = ty - sy

ans = []
# 'U' 'D' 'L' 'R'
# 1
for i in range( ry ):
    ans.append( 'U' )
for i in range( rx ):
    ans.append( 'R' )
# 2
for i in range( ry ):
    ans.append( 'D' )
for i in range( rx ):
    ans.append( 'L' )
# 3
ans.append( 'L' )
for i in range( ry + 1 ):
    ans.append( 'U' )
for i in range( rx + 1 ):
    ans.append( 'R' )
ans.append( 'D' )
# 4
ans.append( 'R' )
for i in range( ry + 1 ):
    ans.append( 'D' )
for i in range( rx + 1 ):
    ans.append( 'L' )
ans.append( 'U' )

print( ''.join(ans) )

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())
ans = ''
if tx - sx > 0:
  if ty - sy > 0:
    x = ['R','L','U','D']
  else:
    x = ['R','L','D','U']
else:
  if ty - sy > 0:
    x = ['L','R','U','D']
  else:
    x = ['L','R','D','U']
ans += x[0]*abs(tx-sx)
ans += x[2]*abs(sy-ty)
ans += x[1]*abs(tx-sx)
ans += x[3]*abs(ty-sy)
ans += x[3] + x[0]*(abs(tx-sx)+1)
ans += x[2]*(abs(ty-sy)+1) + x[1]
ans += x[2] + x[1]*(abs(tx-sx)+1)
ans += x[3]*(abs(ty-sy)+1) + x[0]
print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy
ans = "R" * dx
ans += "U" * dy
ans += "L" * dx
ans += "D" * dy
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:
sx, sy, tx, ty = map(int, input().split())
xf, xb, yf, yb = 'R', 'L', 'U', 'D'
dx = abs(tx - sx)
dy = abs(ty - sy)

if tx < sx:
  xf, xb = 'L', 'R'
if ty < sy:
  yf, yb = 'D', 'U'

s = ""
if dx == 0:
  s += yf*dy
  s += xf
  s += yb*dy
  s += xb
  s += xb
  s += yf*dy
  s += xf
  s += yf
  s += xf*2
  s += yb*(dy+2)
  s += xb*2
  s *= yb
elif dy == 0:
  s += xf*dx
  s += yb
  s += xb*dx
  s += yf
  s += yf
  s += xf*dx
  s += yb
  s += xf
  s += yb*2
  s += xb(dx+2)
  s += yf*2
  s += xf
else:
  s += yf*dy
  s += xf*dx
  s += yb*dy
  s += xb*dx
  s += xb
  s += yf*(dy+1)
  s += xf*(dx+1)
  s += yb
  s += xf
  s += yb*(dy+1)
  s += xb*(dx+1)
  s += yf

print(s)

Submission status: Accepted

Solution code:

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

p1="U"*y+"R"*x
p2="D"*y+"L"*x
p3="L"+"U"*(y+1)+"R"*(x+1)+"D"
p4="R"+"D"*(y+1)+"L"*(x+1)+"U"

print(p1+p2+p3+p4)

Submission status: Accepted

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

iki=["U" for i in range(ty-sy)]+["R" for i in range(tx-sx)]
kaeri=["D" for i in range(ty-sy)]+["L" for i in range(tx-sx)]
iki2=["L"]+["U" for i in range(ty-sy+1)]+["R" for i in range(tx-sx+1)]+["D"]
kaeri2=["R"]+["D" for i in range(ty-sy+1)]+["L" for i in range(tx-sx+1)]+["U"]
ans=iki+kaeri+iki2+kaeri2
print(*ans,sep="")

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
top = ty - sy
right = tx - sx
first = []

for _ in range(top):
    first.append('U')
for _ in range(right):
    first.append('R')


second = []
for char in first:
    if char == 'R':
        second.append('L')
    elif char == 'U':
        second.append('D')


third = ['L']
for _ in range(top + 1):
    third.append('U')
for _ in range(right + 1):
    third.append('R')
third.append('D')

forth = []
for char in third:
    if char == 'R':
        forth.append('L')
    elif char == 'U':
        forth.append('D')
    elif char == 'L':
        forth.append('R')
forth.append('U')
# print(first)
# print(second)
# print(third)
# print(forth)


print(''.join(first) + ''.join(second) + ''.join(third) + ''.join(forth))

Submission status: Accepted

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

ans = []
ans = ans + ['R']*x
ans = ans + ['U']*y

ans = ans + ['L']*x
ans = ans + ['D']*y

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

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

print(''.join(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys


def main():
    sx, sy, tx, ty = map(int, input().split())
    dx = tx - sx
    dy = ty - sy
    ax11 = [("R" if dx >= 0 else "L")] * abs(dx)
    ay11 = [("U" if dy >= 0 else "D")] * abs(dy)
    ax12 = [("L" if dx >= 0 else "R")] * abs(dx)
    ay12 = [("D" if dy >= 0 else "U")] * abs(dy)
    ax21 = [("D" if dy >= 0 else "U")] * 1 + \
        [("R" if dx >= 0 else "L")] * (abs(dx) + 1)
    ay21 = [("U" if dy >= 0 else "D")] * (abs(dy) + 1) + \
        [("L" if dx >= 0 else "R")] * 1
    ax22 = [("U" if dy >= 0 else "D")] * 1 + \
        [("L" if dx >= 0 else "R")] * (abs(dx) + 1)
    ay22 = [("D" if dy >= 0 else "U")] * (abs(dy) + 1) + \
        [("R" if dx >= 0 else "L")] * 1
    a1 = "".join(ax11 + ay11 + ax12 + ay12)
    a2 = "".join(ax21 + ay21 + ax22 + ay22)
    print(a1 + a2)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

short_outward = []
short_return = []
long_outward = ["L"]
long_return = ["R"]

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

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


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

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


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

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

long_outward.append("D")



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

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

long_return.append("U")



list = short_outward+short_return+long_outward+long_return

for i in range(len(list)):
    print(list[i],end="")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
h = abs(sx - tx)
v = abs(sy - ty)
ans = [[1, 0]] * h + [[0, 1]] * v + [[-1, 0]] * h + [[0, -1]] * v
ans += [[0, -1]] + [[1, 0]] * -~h + [[0, 1]] * -~v + [[-1, 0]]
ans += [[0, 1]] + [[-1, 0]] * -~h + [[0, -1]] * -~v + [[1, 0]]
for i in ans:
    if i == [1, 0]:
        print("R", end="")
    elif i == [-1, 0]:
        print("L", end="")
    elif i == [0, 1]:
        print("U", end="")
    else:
        print("D", end="")
print("")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
h = abs(sx - tx)
v = abs(sy - ty)
ans = [[1, 0]] * h + [[0, 1]] * v + [[-1, 0]] * h + [[0, -1]] * v
ans += [[0, -1]] + [[1, 0]] * -~h + [[0, 1]] * -~v + [[-1, 0]]
ans += [[0, 1]] + [[-1, 0]] * -~h + [[0, -1]] * -~v + [[1, 0]]
if x < 0 and y < 0:
    ans = [*map(lambda x: [-x[0], -x[1]], ans)]
elif x < 0:
    ans = [*map(lambda x: [-x[1], x[0]], ans)]
elif y < 0:
    ans = [*map(lambda x: [x[1], -x[0]], ans)]

for i in ans:
    if i == [1, 0]:
        print("R", end="")
    elif i == [-1, 0]:
        print("L", end="")
    elif i == [0, 1]:
        print("U", end="")
    else:
        print("D", end="")
print("")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
h = abs(sx - tx)
v = abs(sy - ty)
if h * v > 0:
    ans = [[1, 0]] * h + [[0, 1]] * v + [[-1, 0]] * h + [[0, -1]] * v
    ans += [[0, -1]] + [[1, 0]] * -~h + [[0, 1]] * -~v + [[-1, 0]]
    ans += [[0, 1]] + [[-1, 0]] * -~h + [[0, -1]] * -~v + [[1, 0]]
elif h < 1:
    ans = [[0, 1]] * v
    ans += [[1, 0]] + [[0, -1]] * v + [[-1, 0]]
    ans += [[-1, 0]] + [[0, 1]] * v + [[1, 0]]
    ans += [[0, 1]] + [[1, 0]] * 2 + [[0, -1]] * \
        (v + 2) + [[-1, 0]] * 2 + [[0, 1]] * 2
elif v < 1:
    ans = [[1, 0]] * h
    ans += [[0, 1]] + [[-1, 0]] * h + [[0, -1]]
    ans += [[0, -1]] + [[1, 0]] * h + [[0, 1]]
    ans += [[1, 0]] + [[0, 1]] * 2 + [[-1, 0]] * \
        (h + 2) + [[0, -1]] * 2 + [[1, 0]] * 2

if x < 0 and y < 0:
    ans = [*map(lambda x: [-x[0], -x[1]], ans)]
elif x < 0:
    ans = [*map(lambda x: [-x[1], x[0]], ans)]
elif y < 0:
    ans = [*map(lambda x: [x[1], -x[0]], ans)]

for i in ans:
    if i == [1, 0]:
        print("R", end="")
    elif i == [-1, 0]:
        print("L", end="")
    elif i == [0, 1]:
        print("U", end="")
    else:
        print("D", end="")
print("")

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 += '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())

if tx > sx and ty > sy:mode=0
elif tx > sx and ty < sy:mode=1
elif tx < sx and ty > sy:mode=3
else: mode=2
  
directions=[('R','U'),('R','D'),('L','D'),('L','U'),('R','U'),('R','D'),('L','D'),('L','U')]

ans=[]
d_go,d_re = directions[mode],directions[mode+2]
dx,dy=abs(tx-sx),abs(ty-sy)
go1 = dx*d_go[0] + dy*d_go[1]
re1 = dx*d_re[0] + dy*d_re[1]
go2 = d_re[1]+(dx+1)*d_go[0] + (dy+1)*d_go[1] + d_re[0]
re2 = d_go[1]+(dx+1)*d_re[0] + (dy+1)*d_re[1] + d_go[0]

ans.extend(go1)
ans.extend(re1)
ans.extend(go2)
ans.extend(re2)

print(''.join(ans))

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque

INF = 1 << 50



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


if __name__ == "__main__":
    run()

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 + 1),
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, sep = "")

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[20]:


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


# In[26]:


ans = []
X = sx; Y = sy
for x in range(sx+1,tx+1):
    ans.append("R")
X = x
for y in range(sy+1,ty+1):
    ans.append("U")
Y = y
for x in reversed(range(sx,tx)):
    ans.append("L")
X = x
for y in reversed(range(sy,ty)):
    ans.append("D")
Y = y
Y -= 1
ans.append("D")
for x in range(sx+1,tx+2):
    ans.append("R")
X = x
for y in range(sy,ty+1):
    ans.append("U")
Y = y
X -= 1
ans.append("L")
Y += 1
ans.append("U")
for x in reversed(range(sx-1,tx)):
    ans.append("L")
X = x
for y in reversed(range(sy,ty+1)):
    ans.append("D")
Y = y
X += 1
ans.append("R")
print("".join(ans))


# In[ ]:

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    sx, sy, tx, ty = [int(item) for item in input().split()]

    gx = tx - sx
    gy = ty - sy

    def r(num):
        return 'R'*num
    
    def l(num):
        return 'L'*num
    
    def u(num):
        return 'U'*num

    def d(num):
        return 'D'*num

    first_trail = l(1) + u(gy+1) + r(gx+1) + d(gy+1) + l(gx)
    second_trail = u(gy) + r(gx+1) + d(gy+1) + l(gx+1) + u(1)

    print(first_trail + second_trail)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split())
X=c-a
Y=d-b
ans1='R'*X+'U'*Y
ans2='L'*X+'D'*Y
ans3='D'+'R'*(X+1)+'U'*(Y+1)+'L'
ans4='U'+'L'*(X+1)+'D'*(Y+1)+'R'
print(ans1+ans2+ans3+ans4)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = ""
# 1周目
ans += (ty-sy)*"U" + (tx-sx)*"R" + (ty-sy)*"D" + (tx-sx)*"L"
# 2周目
ans += "L" + (ty-sy+1)*"U" + (tx-sx+1)*"R" + "DR" + (ty-sy+1)*"D" + (tx-sx+1)*"L" + "U"
print(ans)

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
x1,y1=tx-sx,ty-sy
x2,y2=x1+2,y1+2

s="U"*y1
s+="R"*x1
s+="D"*y1
s+="L"*x1

s+="L"
s+="U"*(y2-1)
s+="R"*(x2-1)
s+="D"

s+="R"
s+="D"*(y2-1)
s+="L"*(x2-1)
s+="U"

print(s)

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))
s = ''
s += 'U'*(l[3]-l[1])
s += 'R'*(l[2]-l[0])
s += 'D'*(l[3]-l[1])
s += 'L'*(l[2]-l[0])
s += 'L'
s += 'U'*(l[3]-l[1]+1)
s += 'R'*(l[2]-l[0]+1)
s += 'D'
s += 'R'
s += 'D'*(l[3]-l[1]+1)
s += 'L'*(l[2]-l[0]+1)
s += 'U'
print(s)

Submission status: Accepted

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

if not ( -1000 <= sx <= 1000 and sx < tx <= 1000 ): sys.exit()
if not ( -1000 <= sy <= 1000 and sy < ty <= 1000 ): sys.exit()
if not ( isinstance(sx,int) and isinstance(sy,int) and isinstance(tx,int) and isinstance(ty,int)): sys.exit()

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

for i in range(tx-sx+1):
    ans+="R"

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

for i in range(tx-sx+1):
    ans+="L"
ans+="UL"

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

for i in range(tx-sx+1):
    ans+="R"

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

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

print(ans)

Submission status: Accepted

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

res = ''

for _ in range(ty-sy):
    res += 'U'
for _ in range(tx-sx):
    res += 'R'

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

res += 'LU'
for _ in range(ty-sy):
    res += 'U'
for _ in range(tx-sx):
    res += 'R'
res += 'RD'

res += 'RD'
for _ in range(ty-sy):
    res += 'D'
for _ in range(tx-sx):
    res += 'L'
res += 'LU'

print(res)

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 j in range(dx):
    ans+="R"
for i in range(dy):
    ans+="D"
for j in range(dx):
    ans+="L"
ans+="L"
for i in range(dy+1):
    ans+="U"
for i in range(dx+1):
    ans+="R"
ans+="DR"
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:
x1,y1,x2,y2=map(int,input().split())
ans=""
ans+="U"*(y2-y1)
ans+="R"*(x2-x1)
ans+="D"*(y2-y1)
ans+="L"*(x2-x1)
ans+="L"
ans+="U"*(y2+1-y1)
ans+="R"*(x2+1-x1)
ans+="D"
ans+="R"
ans+="D"*(y2+1-y1)
ans+="L"*(x2+1-x1)
ans+="U"
print(ans)

Submission status: Accepted

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

ans = ''
if sy < ty:
  v = 'U' * (ty-sy)
  if sx < tx:
    h = 'R' * (tx-sx)
    ans += v + h
    v = 'D' * (ty-sy)
    h = 'L' * (tx-sx)
    ans += v + h
  else:
    h = 'L' * (tx-sx)
    ans += v + h
    v = 'D' * (ty-sy)
    h = 'R' * (tx-sx)
    ans += v + h
else:
  v = 'D' * (sy-ty)
  if sx < tx:
    h = 'R' * (tx-sx)
    ans += v + h
    v = 'U' * (ty-sy)
    h = 'L' * (tx-sx)
    ans += v + h
  else:
    h = 'L' * (tx-sx)
    ans += v + h
    v = 'U' * (ty-sy)
    h = 'R' * (tx-sx)
    ans += v + h
  
if sy < ty:
  v = 'U' * (ty-sy+1)
  if sx < tx:
    h = 'R' * (tx-sx+1)
    ans += 'L' + v + h + 'D'
    v = 'D' * (ty-sy+1)
    h = 'L' * (tx-sx+1)
    ans += 'R' + v + h + 'U'
  else:
    h = 'L' * (tx-sx+1)
    ans += 'R' + v + h + 'D'
    v = 'D' * (ty-sy+1)
    h = 'R' * (tx-sx+1)
    ans += 'L' + v + h + 'U'
else:
  v = 'D' * (sy-ty+1)
  if sx < tx:
    h = 'R' * (tx-sx+1)
    ans += 'L' + v + h + 'U'
    v = 'U' * (ty-sy+1)
    h = 'L' * (tx-sx+1)
    ans += 'R' + v + h + 'D'
  else:
    h = 'L' * (tx-sx+1)
    ans += 'R' + v + h + 'U'
    v = 'U' * (ty-sy+1)
    h = 'R' * (tx-sx+1)
    ans += 'L' + v + h + 'D'
print(ans)

Submission status: Accepted

Solution code:
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

a,b,c,d = MI()
x,y = c-a,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(''.join(ANS))

Submission status: Accepted

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

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

print()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx, sy, tx, ty = [int(w) for w in input().split()]
dx = tx-sx
dy = ty-sy
first = "U"*dy+"R"*dx+"D"*dy+"L"*dx
second = "L"+"U"*(dy+1)+"R"*(dx+1)+"D" +\
         "R"+"D"*(dy+1)+"L"*(dx+1)+"U"

print(first+second)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
sx, sy , tx , ty = map(int , input().split())
dx = tx-sx
dy= ty-sy
now = ""
for i in range(0 ,dy):
	now= now+'U'
for i in range(0 , dx):
	now = now+'R'

for i in range(0 , dy):
	now = now+'D'
for i in range(0 , dx):
	now = now+'L'

now = now+'L'
for i in range(0 , dy+1):
	now = now+'U'
for i in range(0 , dx+1):
	now = now+'R'
now = now+'D'

now = now+'R'
for i in range(0 , dy+1):
	now = now+'D'
for i in range(0 , dx+1):
	now = now+'L'
now = now+'U'
print(now)

Submission status: Accepted

Solution code:
def main():
    import sys

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

    sx, sy, tx, ty = map(int, input().split())
    direction = ['U', 'R', 'D', 'L']
    path = ['']*4
    def inverse(s):
        ret = ''
        for x in s:
            if x == 'U':
                ret += 'D'
            if x == 'R':
                ret += 'L'
            if x == 'D':
                ret += 'U'
            if x == 'L':
                ret += 'R'
        return ret

    path[0] = 'R'*(tx-sx)+'U'*(ty-sy)
    path[2] = 'L'+'U'*(ty-sy+1)+'R'*(tx-sx+1)+'D'
    path[1] = inverse(path[0])
    path[3] = inverse(path[2])
    print(''.join(path))
    
        
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = ""

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

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

print(ans)

Submission status: Accepted

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

x_diff = tx-sx
y_diff = ty-sy

up = 'U'*abs(y_diff)
down = 'D'*abs(y_diff)
left = 'L'*abs(x_diff)
right = 'R'*abs(x_diff)

ans = right+up+left+down
ans = ans+'DR'+right+up+'UL'+'UL'+left+down+'DR'

print(ans)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    S = [0] * 4
    S[0] = 'U' * (ty - sy + 1)
    S[1] = 'R' * (tx - sx + 1)
    S[2] = 'D' * (ty - sy + 1)
    S[3] = 'L' * (tx - sx + 1)
    S = ''.join(S)

    ans = ''.join([S[1:], S[:1], S[-1:], S[:-1]])
    print(ans)

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]
    a,b,x,y = [int(x) for x in input().split()]

    r = x - a
    u = y - b

    ans = ''

    ans += 'D'
    ans += 'R' * (r + 1)
    ans += 'U' * (u + 1)
    ans += 'L'
    ans += 'D' * u
    ans += 'L' * r

    ans += 'L'
    ans += 'U' * (u + 1)
    ans += 'R' * (r + 1)
    ans += 'D'
    ans += 'L' * r
    ans += 'D' * u

    print(ans)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""

Submission status: Accepted

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


    print(move)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A, B, X, Y = map(int, input().split())
P = X-A
Q = Y-B
print("R"*P+"U"*Q+"L"*P+"D"*Q+"L"+"U"*(Q+1)+"R"*(P+1)+"D"+\
"R"+"D"*(Q+1)+"L"*(P+1)+"U")

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())
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())
dx=tx-sx
dy=ty-sy

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

print(moji)

Submission status: Accepted

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

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(10 ** 5)

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

readline = sys.stdin.readline

def process():
    sx, sy, tx, ty = map(int, readline().rstrip().split())
    dx = tx-sx
    dy = ty-sy

    ans = ""
    # covers going both up and down
    ans += 'U'*dy + 'R'*dx + 'D'*dy + 'L'*dx
    # now going up again
    ans += 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D'
    ans += 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'

    return ans

#for _ in range(int(readline().rstrip())):
print(process())