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
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

sx,sy,tx,ty=mint()
ans=[]
dx,dy=tx-sx,ty-sy
R,L,U,D='R','L','U','D'
ans.extend([R]*dx)
ans.extend([U]*dy)
ans.extend([L]*dx)
ans.extend([D]*(dy+1))
ans.extend([R]*(dx+1))
ans.extend([U]*(dy+1))
ans.extend([L,U])
ans.extend([L]*(dx+1))
ans.extend([D]*(dy+1))
ans.extend([R])
lprint(ans,'')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC 051: C – Back and Forth
sx, sy, tx, ty = [int(i) for i in input().split()]

dx = tx - sx
dy = ty - sy

# r1
r1 = 'U' * dy + 'R' * dx

# r2
r2 = 'D' * dy + 'L' * dx

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

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

print(r1 + r2 + r3 + r4)

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int,input().split())
ans = []
ans_out2 = ["D"]
ans_re2 = ["U"]

def solve(sx,sy,tx,ty):
    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")

    for i in range(tx-sx+1):
        ans_out2.append("R")
    for i in range(ty-sy+1):
        ans_out2.append("U")
    ans_out2.append("L")

    for i in range(tx-sx+1):
        ans_re2.append("L")
    for i in range(ty-sy+1):
        ans_re2.append("D")
    ans_re2.append("R")

    list = ans+ans_out2+ans_re2

    return list
  
ans_list = solve(sx,sy,tx,ty)
    
for i in range(len(ans_list)):
    print(ans_list[i],end="")

Submission status: Accepted

Solution code:
def addRoute(i, c):
  t = ''
  for _ in range(i):
    t += c
  return t

pos=list(map(int, input().split()))
ud = pos[3] - pos[1]
rl = pos[2] - pos[0]
s = ''

s += addRoute(ud, 'U')
s += addRoute(rl, 'R')
s += addRoute(ud, 'D')
s += addRoute(rl, 'L')
s += 'L'
s += addRoute(ud+1, 'U')
s += addRoute(rl+1, 'R')
s += 'DR'
s += addRoute(ud+1, 'D')
s += addRoute(rl+1, 'L')
s += 'U'
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

url = "https://atcoder.jp//contests/abc051/tasks/abc051_c"
def search_route(f, t):
    route = ''
    y = t[1] - f[1]
    tmp_y = 'U'*y if y >= 0 else 'D'*(y*-1)
    x = t[0] - f[0]
    tmp_x = 'R'*x if x >= 0 else 'L'*(x*-1)
    route = tmp_y + tmp_x
    return route


def main():
    t = list(map(int, input().split()))
    route = search_route(t[:2], t[2:]) + search_route(t[2:], t[:2])
    tmp = t[:]
    t[0] -= 1
    t[3] += 1
    route_2 = 'L' + search_route(t[:2], t[2:]) + 'D'
    t = tmp
    t[1] -= 1
    t[2] += 1
    route_2 = route_2 + 'R' + search_route(t[2:], t[:2]) + 'U'

    print(route+route_2)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

w = tx - sx
h = ty - sy

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

print(*ans)

Submission status: Accepted

Solution code:
x,y,a,b=map(int,input().split())
a=a-x ; b=b-y 

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

first = "U"*(ty-sy) + "R"*(tx-sx)
second = "D"*(ty-sy) + "L"*(tx-sx)
third = "L" + "U"*(ty-sy+1) + "R"*(tx-sx+1) + "D"
fourth = "R" + "D"*(ty-sy+1) + "L"*(tx-sx+1) + "U"

print(first+second+third+fourth)

Submission status: Accepted

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

higth = ty - sy
width = tx - sx

ans = ''
ans += 'U' * higth
ans += 'R' * width
ans += 'D' * higth
ans += 'L' * width
ans += 'L' + 'U' * (higth + 1)
ans += 'R' * (width + 1) + 'D'
ans += 'R' + 'D' * (higth + 1)
ans += 'L' * (width + 1) + 'U'
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

"""
方針
sx < tx , sy < tyなので
進路としては
1sx,syから右にtx,syまで移動後上にtx,tyまで移動
2tx,tyから左にsx,tyまで移動後下にsx,syまで移動
3下に1移動、右にtx+1,sy-1まで移動、上にtx+1,tyまで移動、左に1移動
4上に1移動、左にsx-1,ty+1まで移動、下にsx-1,syまで移動、右に1移動

"""

up = 'U'
down = 'D'
left = 'L'
right = 'R'

def solve(sx, sy, tx, ty):
    deltax = tx - sx
    deltay = ty - sy
    movelog = ''
    movelog += up * deltay + right * deltax
    movelog += down * deltay + left * deltax
    movelog += down + right * (deltax + 1) + up * (deltay + 1) + left
    movelog += up + left * (deltax + 1) + down * (deltay + 1) + right

    return movelog

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Ans1 = []
Ans2 = []
dx = tx - sx
dy = ty - sy
cnt = abs(dx) + abs(dy)
if dy > 0:
    for i in range(dy):
        Ans1.append("U")
        Ans2.append("D")
else:
    for i in range(-dy):
        Ans1.append("D")
        Ans2.append("U")
if dx > 0:
    for i in range(dx):
        Ans1.append("R")
        Ans2.append("L")
else:
    for i in range(-dx):
        Ans1.append("L")
        ANs2.append("R")

add1 = ["L","U"]
add2 = ["R","D"]

print("".join(Ans1) ,end="")
print("".join(Ans2) ,end="")

if Ans1[0] == "U":
    print("".join(add1),end="")
    print("".join(Ans1) ,end="")
    print("".join(add2),end = "")
    print("".join(add2),end="")
    print("".join(Ans2) ,end="")
    print("".join(add1))
else:
    print("".join(add2),end="")
    print("".join(Ans1) ,end="")
    print("".join(add1),end="")
    print("".join(add1),end="")
    print("".join(Ans2) ,end="")
    print("".join(add2))

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int,input().split())
Way = [''] * 4 
Way[0] = 'R' * (tx-sx) + 'U' * (ty-sy)
Way[1] = 'L' * (tx-sx) + 'D' * (ty-sy)
Way[2] = 'D' + 'R' * (tx-sx+1) + 'U' * (ty-sy+1) + 'L'
Way[3] = 'U' + 'L' * (tx-sx+1) + 'D' * (ty-sy+1) + 'R'
print(''.join(Way))

Submission status: Accepted

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

# first s to t
for _ in range(sx, tx):
    print('R', end='')
for _ in range(sy, ty):
    print('U', end='')

# return t to s
for _ in range(sx, tx):
    print('L', end='')
for _ in range(sy, ty):
    print('D', end='')

#Second s to T
print('D', end='')
for _ in range(sx, tx+1):
    print('R', end='')
for _ in range(sy-1, ty):
    print('U', end='')
print('L', end='')

# Return second t to s
print('U', end='')
for _ in range(sx, tx+1):
    print('L', end='')
for _ in range(sy-1, ty):
    print('D', end='')
print('R', end='')

Submission status: Accepted

Solution code:
p,q,x,y=map(int,input().split())
x-=p
y-=q
u='U'*y+'R'*x
d='D'*y+'L'*x+'LU'
print(u+d+u+'RDRD'+d)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
SX,SY,TX,TY=map(int,input().split())
x=TX-SX
y=TY-SY
print(''.join(['U'*y,'R'*x,'D'*y,'L'*x,'L','U'*(y+1),'R'*(x+1),'D','R','D'*(y+1),'L'*(x+1),'U']))

Submission status: Accepted

Solution code:
SX,SY,TX,TY=map(int,input().split())
vx=TX-SX
vy=TY-SY
print('U'*vy+'R'*vx+'D'*vy+'L'*vx+'L'+'U'*(vy+1)+'R'*(vx+1)+'D'+ 'R'+'D'*(vy+1)+'L'*(vx+1)+'U')

Submission status: Accepted

Solution code:
SX,SY,TX,TY=map(int,input().split())
dt={'U':'D','D':'U','L':'R','R':'L'}
def f(s):
 t=''
 for a in s:t+=dt[a]
 return t

vx=TX-SX
vy=TY-SY

ans1='U'*vy+'R'*vx
ans1+=f(ans1)
ans2='L'+'U'*(vy+1)+'R'*(vx+1)+'D'
ans2+=f(ans2)

print(ans1+ans2)

Submission status: Accepted

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

dt={'U':'D','D':'U','L':'R','R':'L'}

def f(s):
    t=''
    for a in s:
        t+=dt[a]
    return t

vx=TX-SX
vy=TY-SY

ans1=''
ans1=('U' if 0<=vy else 'D')*abs(vy)
ans1+=('R' if 0<=vx else 'L')*abs(vx)
ans1+=f(ans1)

ans2=''
ans2=('R' if 0<=-vx else 'L')
ans2+=('U' if 0<=vy else 'D')*abs(vy+1)
ans2+=('R' if 0<=vx else 'L')*abs(vx+1)
ans2+=('U' if 0<=-vy else 'D')
ans2+=f(ans2)
print(ans1+ans2)

Submission status: Accepted

Solution code:
A,B,C,D = map(int,input().split())
XX = C - A
YY = D - B
if XX >= 0:
  ans1 = 'R'*XX
  ans11 = 'L'*XX
elif XX < 0:
  ans1 = 'L'*abs(XX)
  ans11 = 'R'*abs(XX)
if YY >= 0:
  ans2 = 'U'*YY
  ans22 = 'D'*YY
elif YY < 0:
  ans2 = 'D'*abs(YY)
  ans22 = 'U'*abs(YY)
ans3 = ans1 + ans2
ans4 = ans11 + ans22

if XX >= 0 and YY >= 0:
  ans5 = 'L'+ ans2 +'U' +'R' + ans1 +'D'
  ans55 = 'R' + ans22 + 'D' + 'L' + ans11 + 'U'
elif XX < 0 and YY >= 0:
  ans5 = 'R' + ans2 + 'U' + 'L' + ans1 + 'D'
  ans55 = 'L' + ans22 + 'D' + 'R' + ans11 + 'U'
elif XX >=0 and YY <0:
  ans5 = 'L' + ans2 + 'D' + 'R' + ans1 +'U'
  ans55 = 'R' + ans22 + 'U' + 'L' + ans11 + 'D'
else:
  ans5 = 'R' + ans2 +'D' + 'L' + ans1 + 'U'
  ans55 = 'L' + ans22 + 'U' + 'R' + ans11 + 'D'
print(ans3+ans4+ans5+ans55)

Submission status: Accepted

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

moves = ''

# s -> t (1)
moves += 'U' * dy
moves += 'R' * dx
# t -> s (1)
moves += 'D' * dy
moves += 'L' * dx

# s -> t (2)
moves += 'L'
moves += 'U' * (dy + 1)
moves += 'R' * (dx + 1)
moves += 'D'

# t -> s (2)
moves += 'R'
moves += 'D' * (dy + 1)
moves += 'L' * (dx + 1)
moves += 'U'

print(moves)

Submission status: Accepted

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

Submission status: Accepted

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

#二週目
print("D", end="")
for _ in range(yoko + 1):
    print("R", end="")
for _ in range(tate + 1):
    print("U", end="")
print("L", end="")
#二週半
print("U", end="")
for _ in range(yoko + 1):
    print("L", end="")
for _ in range(tate + 1):
    print("D", end="")
print("R", end="")

Submission status: Accepted

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

Submission status: Accepted

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

    dy = ty - sy
    dx = tx - sx

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

    print(cmd)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

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

    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('D', end='')
    print('R', end='')
    
    for _ in range(ty-sy+1):
        print('D', end='')

    for _ in range(tx-sx+1):
        print('L', end='')

    print('U', end='')

    print()

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
xdiff=tx-sx
ydiff=ty-sy
move=[]
move.append("D")
move+="R"*(xdiff+1)
move+="U"*(ydiff+1)
move+="L"#ここでt到着
move+="U"
move+="L"*(xdiff+1)
move+="D"*(ydiff+1)
move+="R"#ここでs到着
move+="R"*xdiff
move+="U"*ydiff#ここでt到着
move+="L"*xdiff
move+="D"*ydiff#ここでs到着
print(*move,sep="")

Submission status: Accepted

Solution code:
#
# abc051 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """0 0 1 2"""
        output = """UURDDLLUUURRDRDDDLLU"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """-2 -2 1 1"""
        output = """UURRURRDDDLLDLLULUUURRURRDDDLLDL"""
        self.assertIO(input, output)


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

    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)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy

txt = ""
# route 1
txt += dy*"U" + dx*"R"
# route 2
txt += dy*"D" + dx*"L"
# route 3
txt += "L" + (dy+1)*"U" + (dx+1)*"R" + "D"
# route 4
txt += "R" + (dy+1)*"D" + (dx+1)*"L" + "U"

print(txt)

Submission status: Accepted

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

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

print(sol)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


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

    """
    x, y = sx, sy
    for c in ans:
        if c == "U": y += 1
        if c == "D": y -= 1
        if c == "R": x += 1
        if c == "L": x -= 1
        print(x, y)
    """

if __name__ == "__main__":
    main()

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy

res = ""

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

print(res)

Submission status: Accepted

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

# input = stdin.readline

def solve(sx,sy,tx,ty):
  res = []
  dx = tx - sx
  dy = ty - sy
  
  assert dx > 0 and dy > 0
  # 1回目
  res.extend(['R']*dx)
  res.extend(['U']*dy)
  res.extend(['L']*dx)
  res.extend(['D']*dy)

  # 2回目
  res.append('D')
  res.extend(['R']*(dx+1))
  res.extend(['U']*(dy+1))
  res.append('L')

  res.append('U')
  res.extend(['L']*(dx+1))
  res.extend(['D']*(dy+1))
  res.append('R')
  return ''.join(res)


def main():
  sx,sy,tx,ty = map(int,input().split())
  print('{}'.format(solve(sx,sy,tx,ty)))

if __name__ == '__main__':
  main()

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

go = 'U' * (ty - sy) + 'R' * (tx - sx)
back = 'D' * (ty - sy) + 'L' * (tx - sx)
ans = go + back + 'LU' + go + 'RDRD' + back + 'LU'

print(ans)

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy

mx = ["R", "L"]
my = ["U", "D"]

ans = mx[0]*dx + my[0]*dy
ans = ans + mx[1]*dx + my[1]*dy
ans = ans + my[1] + mx[0]*(dx + 1) + my[0]*(dy + 1) + mx[1]
ans = ans + my[0] + mx[1]*(dx + 1) + my[1]*(dy + 1) + mx[0]

print(ans)

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))

num00 = a[3]-a[1]
num01 = a[2]-a[0]
ans = ['U']*num00
ans += ['R']*num01
ans += ['D']*num00
ans += ['L']*num01

ans += ['L']
ans += ['U']*(num00+1)
ans += ['R']*(num01+1)
ans += ['D']

ans += ['R']
ans += ['D']*(num00+1)
ans += ['L']*(num01+1)
ans += ['U']

print(*ans, sep='')

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 += 'DR'
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, raw_input().split())
def f(sx,sy,tx,ty):
	path = ['D']
	path += ['R'] * (abs(tx - sx) + 1)
	path += ['U'] * (abs(ty - sy) + 1)
	path += ['L'] * (abs(tx - sx) + 1)
	path += ['D'] * (abs(ty - sy))
	return path

	
def g(sx,sy,tx,ty):
	path = []
	path += ['R'] * (abs(tx - sx))
	path += ['U'] * (abs(ty - sy) + 1)
	path += ['L'] * (abs(tx - sx)+1)
	path += ['D'] * (abs(ty - sy)+1) 
	return path + ['R']


print ''.join(f(sx,sy, tx,ty) + g(sx,sy,tx,ty))

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int,input().split())
y_diff = ty-sy
x_diff = tx-sx
ans = ""
for i in range(y_diff):
    ans += "U"
for j in range(x_diff):
    ans += "R"
for k in range(y_diff):
    ans += "D"
for l in range(x_diff):
    ans += "L"
ans += "L"
for s in range(y_diff+1):
    ans += "U"
for t in range(x_diff+1):
    ans += "R"
ans += "DR"
for p in range(y_diff+1):
    ans += "D"
for q in range(x_diff+1):
    ans += "L"
ans+="U"
print(ans)

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

rlt = []
for _ in range(tx-sx):
  rlt.append('R')
for _ in range(ty-sy):
  rlt.append('U')
for _ in range(tx-sx):
  rlt.append('L')
for _ in range(ty-sy+1):
  rlt.append('D')
for _ in range(tx-sx+1):
  rlt.append('R')
for _ in range(ty-sy+1):
  rlt.append('U')
rlt.append('L')
rlt.append('U')
for _ in range(tx-sx+1):
  rlt.append('L')
for _ in range(ty-sy+1):
  rlt.append('D')
rlt.append('R')
  
print(''.join(rlt))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
a,b,c,d=MAP()
x=c-a
y=d-b
ans=str()
ans+="R"*x+"U"*y
ans+="L"*x+"D"*y
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())
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 = (int(T) for T in input().split())
print('R'*(TX-SX)+'U'*(TY-SY)+'L'*(TX-SX)+'D'*(TY-SY)+'D'+'R'*(TX-SX+1)+'U'*(TY-SY+1)+'L'+'U'+'L'*(TX-SX+1)+'D'*(TY-SY+1)+'R')

Submission status: Accepted

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

x=c-a
y=d-b

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

print(t)

Submission status: Accepted

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

dy = tx - sx
dx = ty - sy

ans = ''

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    sx,sy,tx,ty=map(int,input().split())
    s=(sx,sy)
    t=(tx,ty)
    dif_y = abs(ty-sy)
    dif_x = abs(tx-sx)
    ans = "U"*dif_y+"R"*dif_x
    ans += "D"*dif_y+"L"*dif_x
    ans += "L"+"U"*(dif_y+1)+"R"*(dif_x+1)+"D"
    ans += "R"+"D"*(dif_y+1)+"L"*(dif_x+1)+"U"
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# coding = SJIS

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

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

print(way)

Submission status: Accepted

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

ans+='R'*dx
ans+='U'*dy
ans+='L'*dx
ans+='D'*dy
ans+='DR'
ans+='R'*dx
ans+='U'*dy
ans+='ULUL'
ans+='L'*dx
ans+='D'*dy
ans+='DR'

print(ans)

Submission status: Accepted

Solution code:
import math
a,b,c,d=map(int,input().split())
ans=""
for i in range (c-a):
    ans+="R"
for i in range (d-b):
    ans+="U"
for i in range (c-a):
    ans+="L"
for i in range (d-b):
    ans+="D"
ans+="D"
for i in range (c-a+1):
    ans+="R"
for i in range (d-b+1):
    ans+="U"
ans+="LU"
for i in range (c-a+1):
    ans+="L"
for i in range (d-b+1):
    ans+="D"
ans+="R"
print(ans)

Submission status: Accepted

Solution code:
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

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

Submission status: Accepted

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

dx = tx-sx
dy = ty-sy

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

Submission status: Accepted

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

s = ["L"]+["U"]*(dy+1)+["R"]*(dx+1)+["D"] + ["R"]+["D"]*(dy+1)+["L"]*(dx+1)+["U"] + ["U"]*dy+["R"]*dx + ["D"]*dy+["L"]*dx
print("".join(s))

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
if y>0:
    p,r='U','D'
else:
    p,r='D','U'
if x>0:
    q,s='R','L'
else:
    q,s='L','R'
l=[p]*y+[q]*x+[r]*y+[s]*x+[s]+[p]*(y+1)+[q]*(x+1)+[r]+[q]+[r]*(y+1)+[s]*(x+1)+[p]
print(''.join(l))

Submission status: Accepted

Solution code:
sx, sy, tx, ty = [int(s) for s in input().split(" ")]
diff = [tx - sx, ty - sy]

print("R" * diff[0] + "U" * diff[1] + "L" * diff[0] + "D" * diff[1] + "D" + "R" * (diff[0] + 1) + "U" * (diff[1] + 1) + "L" + "U" + "L" * (diff[0] + 1) + "D" * (diff[1] + 1) + "R")

Submission status: Accepted

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

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

print(ans)