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
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

x1,y1,x2,y2=MI()
dx=x2-x1
dy=y2-y1
for i in range(dx):
    print("R",end="")
for i in range(dy):
    print("U",end="")
for i in range(dx):
    print("L",end="")
for i in range(dy):
    print("D",end="")
print("L",end="")
for i in range(dy+1):
    print("U",end="")
for i in range(dx+1):
    print("R",end="")
print("D",end="")
print("R",end="")
for i in range(dy+1):
    print("D",end="")
for i in range(dx+1):
    print("L",end="")
print("U")

Submission status: Accepted

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

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

xdist = tx - sx
ydist = ty - sy

ans = "R" * xdist + "U" * ydist + "L" * xdist + "D" * ydist

ans += "L" + (ydist + 1) * "U" + "R" * (xdist + 1) + "D"
ans += "R" + (ydist + 1) * "D" + "L" * (xdist + 1) + "U"

print(ans)

Submission status: Accepted

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

route = []
dy = gy - sy
dx = gx - sx
route.append('U' * dy)
route.append('R' * dx)
route.append('D' * dy)
route.append('L' * (dx + 1))
route.append('U' * (dy + 1))
route.append('R' * (dx + 1))
route.append('DR')
route.append('D' * (dy + 1))
route.append('L' * (dx + 1))
route.append('U')
print(''.join(route))

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    sx,sy,tx,ty=map(int,readline().split())

    ans=""
    u=ty-sy
    v=tx-sx
    a=u*"U"
    b=v*"R"
    c=u*"D"
    d=v*"L"
    ans+=a+b+c+d
    ans+="L"+a+"U"+b+"R"+"D"
    ans+="R"+c+"D"+d+"L"+"U"
    print(ans)

if __name__=="__main__":
    main()

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

print(ans)

Submission status: Accepted

Solution code:
X = list(map(int, input().split()))
sx = X[0]
sy = X[1]
tx = X[2]
ty = X[3]
x = tx - sx
y = ty - sy
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:
sx,sy,tx,ty=map(int,input().split())
height=ty-sy
width=tx-sx
ans=""
ans+='U'*height+'R'*width+'D'*height+'L'*width
ans+='L'+'U'*(height+1)+'R'*(width+1)+'D'
ans+='R'+'D'*(height+1)+'L'*(width+1)+'U'
print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

sx, sy, tx, ty = MAP()
X = tx - sx
Y = ty - sy

way1 = "R"*X + "U"*Y
way2 = "L"*X + "D"*Y
way3 = "L" + "U"*(Y+1) + "R"*(X+1) + "D"
way4 = "R" + "D"*(Y+1) + "L"*(X+1) + "U"

print(way1+way2+way3+way4)

Submission status: Accepted

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

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


print("".join(R))

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split())
x=c-a
y=d-b
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 = list(map(int, input().strip().split()))
dx = tx-sx
dy = ty-sy
result = ""
for i in range(dy):
  result += "U"
for i in range(dx):
  result += "R"
for i in range(dy):
  result += "D"
for i in range(dx):
  result += "L"
result += "L"
  
for i in range(dy+1):
  result += "U"
for i in range(dx+1):
  result += "R"
result += "DR"
for i in range(dy+1):
  result += "D"
for i in range(dx+1):
  result += "L"
result += "U"
print(result)

Submission status: Accepted

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

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

Submission status: Accepted

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

move = ''
xz = abs(tx-sx)
yz = abs(ty-sy)
move += 'U'*yz + 'R'*xz + 'D'*yz + 'L'*xz
move += 'L'*1 + 'U'*(yz+1) + 'R'*(xz+1) + 'D'*1
move += 'R'*1 + 'D'*(yz+1) + 'L'*(xz+1) + 'U'*1
print(move)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x_s, y_s, x_t, y_t = map(int, input().split())
dist_x, dist_y = x_t - x_s, y_t - y_s

ans = ""
ans += ("R" * dist_x)
ans += ("U" * dist_y)
ans += ("L" * dist_x)
ans += ("D" * dist_y)
ans += "D"
ans += ("R" * (dist_x + 1))
ans += ("U" * (dist_y + 1))
ans += "LU"
ans += ("L" * (dist_x + 1))
ans += ("D" * (dist_y + 1))
ans += "R"

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

diff_x = abs(tx-sx)
diff_y = abs(ty-sy)

# 最短距離で行って戻る
ans += "U" * diff_y + "R" * diff_x
ans += "D" * diff_y + "L" * diff_x

# 一歩左に進んでから、ty+1の位置まで上に進む。
ans += "L" * 1 + "U" * (diff_y+1)
# txの位置まで右に進んでから、一歩下に進む。
ans += "R" * (diff_x+1) + "D" * 1

# 一歩右に進んでから、sy-1の位置まで下に進む。
ans += "R" * 1 + "D" * (diff_y+1)
# sxの位置まで左に進んでから、一歩上に進む。
ans += "L" * (diff_x+1) + "U" * 1

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import deque


def read():
    sx, sy, tx, ty = map(int, input().strip().split())
    return sx, sy, tx, ty


def solve(sx, sy, tx, ty):
    dx = tx - sx
    dy = ty - sy
    q = deque()
    q.append("U" * dy)
    q.append("R" * dx)
    q.append("D" * dy)
    q.append("L" * dx)
    q.append("L" * 1)
    q.append("U" * (dy+1))
    q.append("R" * (dx+1))
    q.append("D" * 1)
    q.append("R" * 1)
    q.append("D" * (dy+1))
    q.append("L" * (dx+1))
    q.append("U" * 1)
    return "".join(q)


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans1=x*"R"+y*"U"
ans2=x*"L"+y*"D"
ans3="D"+(1+x)*"R"+(1+y)*"U"+"L"
ans4="U"+(1+x)*"L"+(1+y)*"D"+"R"


ans = ans1+ans2+ans3+ans4
print(ans)

Submission status: Accepted

Solution code:
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

def reverse(temp):
    out = ""
    for x in temp:
        if x == "U":
            out += "D"
        elif x == "D":
            out += "U"
        elif x == "R":
            out += "L"
        else:
            out += "R"
    return out

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

A = ""
B = ""
C = ""
D = ""

# A
if sy < ty:
    A += "U" * (ty-sy)
else:
    A += "D" * (sy-ty)
if sx < tx:
    A += "R" * (tx-sx)
else:
    A += "L" * (sx-tx)
B = reverse(A)

C+=B[-1]+A[0]+A+A[-1]+B[0]
D = reverse(C)


print(A+B+C+D)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
ver = ty - sy
hor = tx - sx
go1 = 'U'*ver+"R"*hor
back1 = "D"*ver+"L"*hor
go2 = "D"+"R"*(hor+1)+'U'*(ver+1)+"L"
back2 = "U"+"L"*(hor+1)+"D"*(ver+1)+"R"
print(go1+back1+go2+back2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
sx, sy, tx, ty = map(int, input().split())
dx,dy = tx-sx, ty-sy

r1 = 'U'*dy + 'R'*dx
r2 = 'D'*dy + 'L'*dx

r3 = 'LU'+r1+'RD'
r4 = 'RD'+r2+'LU'

print(r1+r2+r3+r4)

Submission status: Accepted

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

Submission status: Accepted

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

def print_route(sx,sy,tx,ty,goback,route):
    if goback == 'go':
        for i in range(tx-sx):
            route += 'R'
        for j in range(ty-sy):
            route += 'U'
    elif goback == 'back':
        for i in range(tx-sx):
            route += 'L'
        for j in range(ty-sy):
            route += 'D'
    else:
        pass
    return route
    
route = ""
route = print_route(sx,sy,tx,ty,'go',route)
route = print_route(sx,sy,tx,ty,'back',route)
route += 'D'
route = print_route(sx,sy-1,tx+1,ty,'go',route)
route += 'LU'
route = print_route(sx-1,sy,tx,ty+1,'back',route)
route += 'R'
print(route)

Submission status: Accepted

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

dx = tx-sx
dy = ty-sy

# first
path.append('U'*dy)
path.append('R'*dx)

# second
path.append('D'*dy)
path.append('L'*dx)

# third
path.append('L')
path.append('U'*(dy+1))
path.append('R'*(dx+1))
path.append('D')

# forth
path.append('R')
path.append('D'*(dy+1))
path.append('L'*(dx+1))
path.append('U')

print(''.join(path))

Submission status: Accepted

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

order = "L"

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

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

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

Submission status: Accepted

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

ans = ''

# 1回目の現在点から目的点への移動
cnt_ud = abs(ty-sy)
cnt_rl = abs(sx-tx)
ans += 'U'*cnt_ud+'R'*cnt_rl

# 1回目の目的点から現在点への移動
ans += 'D'*cnt_ud+'L'*cnt_rl

# 2回目の現在点から目的点への移動
ans += 'L'+'U'*(cnt_ud+1)+'R'*(cnt_rl+1)+'D'

# 2回目の目的点から現在点への移動
ans += 'R'+'D'*(cnt_ud+1)+'L'*(cnt_rl+1)+'U'

print(ans)

Submission status: Accepted

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

xd = tx - sx
yd = ty - sy

route1 = []
route1.append('R'*xd)
route1.append('U'*yd)

route2 = []
route2.append('L'*xd)
route2.append('D'*yd)

route3 = ['D']
route3.append('R' * (xd + 1))
route3.append('U' * (yd + 1))
route3.append('L')

route4 = ['U']
route4.append('L'*(xd+1))
route4.append('D'*(yd+1))
route4.append('R')

ans = ''.join(route1) + ''.join(route2) + ''.join(route3) + ''.join(route4)
print(ans)

Submission status: Accepted

Solution code:
import sys


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


def resolve():
    s1, s2, t1, t2 = map(int, input().split())
    l = []
    x = t1 - s1
    y = t2 - s2
    ans='R'*x+'U'*y+'L'*x+'D'*y
    ans+='D'+'R'*(x+1)+'U'*(y+1)+'L'
    ans+='U'+'L'*(x+1)+'D'*(y+1)+'R'
    print(ans)
resolve()

Submission status: Accepted

Solution code:
import sys


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


def resolve():
    s1, s2, t1, t2 = map(int, input().split())
    l = []
    yoko = t1 - s1
    tate = t2 - s2
    a,c,f,h='R','L','L','R'
    b,d,e,g='U','D','D','U'
    l.append(a*yoko+b*tate+c*yoko+d*tate)
    l.append(e+a*(yoko+1)+b*(tate+1)+f)
    l.append(g+c*(yoko+1)+d*(tate+1)+h)
    print(''.join(l))
resolve()

Submission status: Accepted

Solution code:
import sys


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


def resolve():
    s1, s2, t1, t2 = map(int, input().split())
    l = []
    yoko = t1 - s1
    tate = t2 - s2
    if yoko>0:
        a,c,f,h='R','L','L','R'
    else:
        yoko=-yoko
        a,c,f,h='L','R','R','L'
    if tate>0:
        b,d,e,g='U','D','D','U'
    else:
        tate=-tate
        b,d,e,g='D','U','U','D'
    l.append(a*yoko+b*tate+c*yoko+d*tate)
    l.append(e+a*(yoko+1)+b*(tate+1)+f)
    l.append(g+c*(yoko+1)+d*(tate+1)+h)
    print(''.join(l))
resolve()

Submission status: Accepted

Solution code:
import sys


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


def resolve():
    s1, s2, t1, t2 = map(int, input().split())
    l = []
    yoko = t1 - s1
    tate = t2 - s2
    if yoko>0:
        a='R'
        c='L'
        f='L'
        h='R'
    else:
        yoko=-yoko
        a='L'
        c='R'
        f='R'
        h='L'
    if tate>0:
        b='U'
        d='D'
        e='D'
        g='U'
    else:
        tate=-tate
        b='D'
        d='U'
        e='U'
        g='D'
    l.append(a*yoko+b*tate+c*yoko+d*tate)
    l.append(e+a*(yoko+1)+b*(tate+1)+f)
    l.append(g+c*(yoko+1)+d*(tate+1)+h)
    print(''.join(l))
resolve()

Submission status: Accepted

Solution code:
import sys


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


def resolve():
    s1, s2, t1, t2 = map(int, input().split())
    l = []
    yoko = t1 - s1
    tate = t2 - s2
    if yoko > 0 and tate > 0:
        l.append('R' * yoko + 'U' * tate)
        l.append('L' * yoko + 'D' * tate)
        l.append('D' + 'R' * (yoko + 1) + 'U' * (tate + 1) + 'L')
        l.append('U' + 'L' * (yoko + 1) + 'D' * (tate + 1) + 'R')
        print(''.join(l))
    elif yoko > 0 and tate < 0:
        tate = -tate
        l.append('R' * yoko + 'D' * tate)
        l.append('L' * yoko + 'U' * tate)
        l.append('U' + 'R' * (yoko + 1) + 'D' * (tate + 1) + 'L')
        l.append('D' + 'L' * (yoko + 1) + 'U' * (tate + 1) + 'R')
        print(''.join(l))
    elif yoko < 0 and tate > 0:
        yoko = -yoko
        l.append('L' * yoko + 'U' * tate)
        l.append('R' * yoko + 'D' * tate)
        l.append('D' + 'L' * (yoko + 1) + 'U' * (tate + 1) + 'R')
        l.append('U' + 'R' * (yoko + 1) + 'D' * (tate + 1) + 'L')
        print(''.join(l))
    else:
        yoko = -yoko
        tate = -tate
        l.append('L' * yoko + 'D' * tate)
        l.append('R' * yoko + 'U' * tate)
        l.append('U' + 'L' * (yoko + 1) + 'D' * (tate + 1) + 'R')
        l.append('D' + 'R' * (yoko + 1) + 'U' * (tate + 1) + 'L')
        print(''.join(l))
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

ans=[]

#sの上->tの左 ↑→
sx1=sx
sy1=sy+1
tx1=tx-1
ty1=ty
ans.append('U')
ans.extend(['U']*(ty1-sy1))
ans.extend(['R']*(tx1-sx1))
ans.append('R')

#tの下->sの右  ↓←
sx2=sx+1
sy2=sy
tx2=tx
ty2=ty-1
ans.append('D')
ans.extend(['D']*(ty2-sy2))
ans.extend(['L']*(tx2-sx2))
ans.append('L')

#sの下->tの右 ↓→↑←
sx3=sx
sy3=sy-1
tx3=tx+1
ty3=ty
ans.append('D')
ans.extend(['R']*(tx3-sx3))
ans.extend(['U']*(ty3-sy3))
ans.append('L')

#tの上->sの左 ↑←↓→
sx4=sx-1
sy4=sy
tx4=tx
ty4=ty+1
ans.append('U')
ans.extend(['L']*(tx4-sx4))
ans.extend(['D']*(ty4-sy4))
ans.append('R')

print(''.join(ans))

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
directions = ['U', 'D', 'L', 'R']

print(directions[0] * (ty - sy), end='')
print(directions[3] * (tx - sx), end='')
print(directions[1] * (ty - sy), end='')
print(directions[2] * (tx - sx), end='')
print(directions[2], end='')
print(directions[0] * (ty - sy + 1), end='')
print(directions[3] * (tx - sx + 1), end='')
print(directions[1], end='')
print(directions[3], end='')
print(directions[1] * (ty - sy + 1), end='')
print(directions[2] * (tx - sx + 1), end='')
print(directions[0])

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print("".join(ans))

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int,input().split())
# 距離 s < tより
dx = tx - sx
dy = ty - sy

res = ""
# 1回目
# いきし
for i in range(dx):
    res += "R"
for i in range(dy):
    res += "U"
# かえりし
for i in range(dx):
    res += "L"
for i in range(dy):
    res += "D"

# 2回目
# いきし 1回上に上がる dx + 1いく
res += "D"
for i in range(dx+1):
    res += "R"
for i in range(dy+1):
    res += "U"
res += "L"
# かえりし 1回下がっとく
res += "U"
for i in range(dx+1):
    res += "L"
for i in range(dy+1):
    res += "D"
res += "R"
print(res)

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import *

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())
# x→yの順に処理していけば良い。
iki_x = tx - sx
iki_y = ty - sy
ans = ""
ans += "R" * iki_x
ans += "U" * iki_y
ans += "L" * iki_x
ans += "D" * iki_y
ans += "D"
ans += "R" * (iki_x + 1)
ans += "U" * (iki_y + 1)
ans += "L"
ans += "U"
ans += "L" * (iki_x + 1)
ans += "D" * (iki_y + 1)
ans += "R"
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

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

tx -= sx
ty -= sy

s = str()
s += 'R' * tx
s += 'U' * ty
s += 'L' * tx
s += 'D' * (ty + 1)
s += 'R' * (tx + 1)
s += 'U' * (ty + 1)
s += 'L'
s += 'U'
s += 'L' * (tx + 1)
s += 'D' * (ty + 1)
s += 'R'

print (s)

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

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int,input().split())
ans = ''
s1 = (sx,sy+1)
s2 = (sx+1,sy)
s3 = (sx-1,sy)
s4 = (sx,sy-1)
t1 = (tx-1,ty)
t2 = (tx,ty-1)
t3 = (tx,ty+1)
t4 = (tx+1,ty)
l = [s1,t1,s2,t2,s3,t3,s4,t4]
for i in range(4):
    xs,ys = l[i*2]
    xt,yt = l[i*2+1]
    if i%2==0:
        if i == 0:
            ans += 'U'
        else:
            ans += 'L'
        ans += 'U'*(yt-ys)
        ans += 'R'*(xt-xs)
        if i == 0:
            ans += 'R'
        else:
            ans += 'D'
    else:
        if i == 1:
            ans += 'D'
        else:
            ans += 'R'
        ans += 'D'*(yt-ys)
        ans += 'L'*(xt-xs)
        if i == 1:
            ans += 'L'
        else:
            ans += 'U'
    #print(ans)
    #print(yt-ys,xt-xs)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(path)

Submission status: Accepted

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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    sx, sy, tx, ty = mi()
    xdiff = tx - sx
    ydiff = ty - sy
    print('R'*xdiff+'U'*ydiff + 'L'*xdiff+'D'*ydiff + 'D'+'R'*(xdiff+1)+'U'*(ydiff+1)+'L' + 'U'+'L'*(xdiff+1)+'D'*(ydiff+1)+'R')


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
Sx,Sy,Tx,Ty = map(int,input().split())

dx = Tx - Sx
dy = Ty - Sy
 
ans1 = "U"*dy + "R"*dx
ans2 = "D"*dy + "L"*dx
ans3 = "L" + "U"*(dy+1) + "R"*(dx+1) + "D"
ans4 = "R" + "D"*(dy+1) + "L"*(dx+1) + "U"
 
print(ans1 + ans2 + ans3 + ans4)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    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)
    

if __name__ == '__main__':
    main()

Submission status: Accepted

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

res = ""
for i in range(dy): res += "U"
for i in range(dx): res += "R"
for i in range(dy): res += "D"
for i in range(dx): res += "L"

res += "L"
for i in range(dy+1): res += "U"
for i in range(dx+1): res += "R"
res += "D"
res += "R"
for i in range(dy+1): res += "D"
for i in range(dx+1): res += "L"
res += "U"

print(res)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
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:
def main():
    sx, sy, tx, ty = map(int, input().split())
    move1 = []
    move2 = []
    for i in range(abs(sx-tx)):
        if sx > tx:
            move1.append("L")
        else:
            move1.append("R")

    for j in range(abs(sy-ty)):
        if sy > ty:
            move2.append("D")
        else:
            move2.append("U")

    move3 = [reverse(m) for m in move1]
    move4 = [reverse(m) for m in move2]
    
    move5 = [reverse(move2[0])] + move1
    move5.append(move1[-1])
    
    move6 = [move2[0]] + move2
    move6.append(reverse(move1[0]))

    move7 = [reverse(m) for m in move5]
    move8 = [reverse(m) for m in move6]

    move = move1 + move2 + move3 + move4 + move5 + move6 + move7 + move8
    move_str = ""

    for m in move:
        move_str += m
    print(move_str)    


def reverse(m):
    if m == "D":
        return "U"
    elif m == "U":
        return "D"
    elif m == "R":
        return "L"
    else:
        return "R"

    
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

ans += 'U' * ty + 'R' * tx + 'D' * ty + 'L' * tx
ans += 'L' + 'U' * (ty + 1) + 'R' * (tx + 1) + 'DR' + 'D' * (ty + 1) + 'L' * (tx + 1) + 'U'
print(ans)

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy
path1 = 'U' * dy + 'R' * dx
path2 = 'D' * dy + 'L' * dx
path3 = 'L' + 'U' * (dy+1) + 'R' * (dx+1) + 'D'
path4 = 'R' + 'D' * (dy+1) + 'L' * (dx+1) + 'U'
print(path1 + path2 + path3 + path4)