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

Submission status: Accepted

Solution code:
def move(direction, x, y):
    tmp_x, tmp_y = x, y
    if direction == 'U': tmp_y += 1
    if direction == 'D': tmp_y -= 1
    if direction == 'L': tmp_x -= 1
    if direction == 'R': tmp_x += 1
    print(direction, end = '')
    return tmp_x, tmp_y

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

x, y = sx, sy

# 往路1
while x != tx:
    x, y = move('R', x, y)
while y != ty:
    x, y = move('U', x, y)
# 復路1
while x != sx:
    x, y = move('L', x, y)
while y != sy:
    x, y = move('D', x, y)
# 往路2
x, y = move('D', x, y)
while x != tx:
    x, y = move('R', x, y)
x, y = move('R', x, y)
while y != ty:
    x, y = move('U', x, y)
x, y = move('L', x, y)
# 復路2
x, y = move('U', x, y)
while x != sx:
    x, y = move('L', x, y)
x, y = move('L', x, y)
while y != sy:
    x, y = move('D', x, y)
x, y = move('R', x, y)

print('')

Submission status: Accepted

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

Submission status: Accepted

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

gx, gy = tx-sx, ty-sy

r1 = 'U'*gy + 'R'*gx
r2 = 'D'*gy + 'L'*gx
r3 = 'L' + 'U'*(gy+1) + 'R'*(gx+1) + 'D'
r4 = 'R' + 'D'*(gy+1) + 'L'*(gx+1) + 'U'
print(r1 + r2 + r3 + r4)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = (int(x) for x in input().split())
print_list = []
# 一回目
for i in range(abs(tx - sx)):
    print_list.append("R")
for i in range(abs(ty - sy)):
    print_list.append("U")
# 二回目
for i in range(abs(tx - sx)):
    print_list.append("L")
for i in range(abs(ty - sy)):
    print_list.append("D")
# 三回目
print_list.append("D")
for i in range(abs(tx - sx) + 1):
    print_list.append("R")
for i in range(abs(ty - sy) + 1):
    print_list.append("U")
print_list.append("L")
# 四回目
print_list.append("U")
for i in range(abs(tx - sx) + 1):
    print_list.append("L")
for i in range(abs(ty - sy) + 1):
    print_list.append("D")
print_list.append("R")
print("".join(print_list))

Submission status: Accepted

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


for _ in range(dx):
	res.append("R")
for _ in range(dy):
	res.append("U")
for _ in range(dx):
	res.append("L")
for _ in range(dy):
	res.append("D")

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

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

Submission status: Accepted

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


for i in range(ty - sy):
    print("U", end="")

for i in range(tx - sx):
    print("R", end="")

for i in range(ty - sy):
    print("D", end="")

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

for i in range(ty - sy + 1):
    print("U", end="")

for i in range(tx - sx + 1):
    print("R", end="")

print("D", end="")
print("R", end="")

for i in range(ty - sy + 1):
    print("D", end="")

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

print("U", end="")

Submission status: Accepted

Solution code:


def main():
    a, b, c, d = map(int, input().split())

    for i in range(d - b):
        print('U', end='')

    for i in range(c - a):
        print('R', end='')

    for i in range(d - b):
        print('D', end='')

    for i in range(c - a):
        print('L', end='')

    print('L', end='')

    for i in range(d - b + 1):
        print('U', end='')

    for i in range(c - a + 1):
        print('R', end='')

    print('D', end='')

    print('R', end='')

    for i in range(d - b + 1):
        print('D', end='')

    for i in range(c - a + 1):
        print('L', end='')

    print('U')




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split())
x,y=c-a,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 = map(int, input().split())
dx,dy = (tx-sx),(ty-sy)
p1 = "U"*dy+"R"*dx
p2 = "D"*dy+"L"*dx
p3 = "L"+"U"*(dy+1)+"R"*(dx+1)+"D"
p4 = "R"+"D"*(dy+1)+"L"*(dx+1)+"U"
print(p1+p2+p3+p4)

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:
import sys
import math

sys.setrecursionlimit(1000)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return [int(x) for x in input().split()]
MOD = 10**9 + 7

sx, sy, tx, ty = LIST()
dx = tx - sx
dy = ty - sy

trace = ""

# 1
trace += 'R' * dx
trace += 'U' * dy

# 2
trace += 'L' * dx
trace += 'D' * dy

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

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

print(trace)

Submission status: Accepted

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

x=tx-sx
y=ty-sy

r="R"
d="D"
u="U"
l="L"


ans=""

ans+=(r*abs(x))
ans+=(u*abs(y))
ans+=(l*abs(x))
ans+=(d*abs(y))
ans+=(d)
ans+=(r*abs(x+1))
ans+=(u*abs(y+1))
ans+=(l)
ans+=(u)
ans+=(l*abs(x+1))
ans+=(d*abs(y+1))
ans+=(r)


print(ans)

Submission status: Accepted

Solution code:

def main():
    sx,sy,tx,ty = map(int,input().split())
    subx = tx-sx
    suby = ty-sy
    if subx>=0:
        ls1 = "R"*subx
        ls3 = "L"*subx
    else:
        ls1 = "L"*(-subx)
        ls3 = "R"*(-subx)
    if suby>=0:
        ls2 = "U"*suby
        ls4 = "D"*suby
    else:
        ls2 = "D"*(-suby)
        ls4 = "U"*(-suby)
    first = ls1 + ls2 + ls3 + ls4
    second = ls4[0] + (ls1 + ls1[0]) + (ls2 + ls2[0]) + ls3[0] + ls2[0] + (ls3 + ls3[0]) + (ls4 + ls4[0]) + ls1[0]
    ans = first + second
    print("".join(ans))
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = input()
    print(" ".join(a.split(",")))
    return

#B
def B():
    k, s = LI()
    ans = 0
    for i in range(k + 1):
        for j in range(k + 1):
            if 0 <= s - (i + j) <= k:
                ans += 1
    print(ans)
    return

#C
def C():
    sx, sy, tx, ty = LI()
    UD = ("U", "D")
    LR = ("R", "L")
    ans = UD[sy > ty] * (abs(sy - ty)) + LR[sx > tx] * (abs(sx - tx))
    ans += UD[ty > sy] * (abs(sy - ty)) + LR[tx > sx] * (abs(sx - tx))
    ans += LR[tx > sx] + UD[sy > ty] * (abs(sy - ty) + 1) + LR[sx > tx] * (abs(sx - tx) + 1) + UD[ty > sy]
    ans += LR[sx > tx] + UD[ty > sy] * (abs(sy - ty) + 1) + LR[tx > sx] * (abs(sx - tx) + 1) + UD[sy > ty]
    print(ans)
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Accepted

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

Submission status: Accepted

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

#s = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
sx=hoge[0]
sy=hoge[1]
tx=hoge[2]
ty=hoge[3]


ans = ""

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

for i in range(0,tx-sx):
	ans+="L"
for i in range(0,ty-sy):
	ans+="D"

for i in range(0,tx-sx):
	ans+="R"
for i in range(0,ty-sy):
	ans+="U"

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

print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, raw_input().split())
tx -= (sx - 1)
sx = 1
ty -= (sy - 1)
sy = 0

def solve(tx, ty):
    res = []
    for i in range(1, ty):
        res.append("U")
    for i in range(1, tx):
        res.append("R")
    for i in range(ty, 1, -1):
        res.append("D")
    for i in range(tx, 1, -1):
        res.append("L")
    res += "L"
    for i in range(1, ty + 1):
        res.append("U")
    for i in range(0, tx):
        res.append("R")
    res += "DR"
    for i in range(ty, 0, -1):
        res.append("D")
    for i in range(tx, 0, -1):
        res.append("L")
    res.append("U")
    return "".join(res)
print solve(tx, ty)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
up = "U" * (ty - sy)
right = "R" * (tx - sx)
down = up.replace("U", "D")
left = right.replace("R", "L")
first = up + right + down + left
second = "LU" + up + right + "RDRD" + down + left + "LU"
print(first+second)

Submission status: Accepted

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

rangex = tx-sx
rangey = ty-sy
# 行ったりきたりで4回
for y in range(rangey):
  print("U", end="")
for x in range(rangex):
  print("R", end="")

# 帰り
for y in range(rangey):
  print("D", end="")
for x in range(rangex):
  print("L", end="")

  
print("L", end="")
for y in range(rangey + 1):
  print("U", end="")
for x in range(rangex + 1):
  print("R", end="")

print("D", end="")

# 帰り
print("R", end="")
for y in range(rangey + 1):
  print("D", end="")
for x in range(rangex+1):
  print("L", end="")

print("U", end="")

Submission status: Accepted

Solution code:
def solve(dx, dy):
    a = 'U'*dy+'R'*dx
    b = 'D'*dy+'L'*dx
    c = 'L'+'U'*(dy+1)+'R'*(dx+1)+'D'
    d = 'R'+'D'*(dy+1)+'L'*(dx+1)+'U'
    return a+b+c+d


if __name__ == '__main__':
    sx, sy, tx, ty = map(int, input().split())
    dx = abs(tx-sx)
    dy = abs(ty-sy)
    print(solve(dx, dy))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(sx: int, sy: int, tx: int, ty: int):
    ret = ''
    ret += 'U' * (ty - sy)
    ret += 'R' * (tx - sx)
    ret += 'D' * (ty - sy)
    ret += 'L' * (tx - sx + 1)
    ret += 'U' * (ty - sy + 1)
    ret += 'R' * (tx - sx + 1)
    ret += 'D'
    ret += 'R'
    ret += 'D' * (ty - sy + 1)
    ret += 'L' * (tx - sx + 1)
    ret += 'U'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    sx = int(next(tokens))  # type: int
    sy = int(next(tokens))  # type: int
    tx = int(next(tokens))  # type: int
    ty = int(next(tokens))  # type: int
    solve(sx, sy, tx, ty)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC51 C
sx,sy,tx,ty = map(int,input().split())

ans = ''
for _ in range(ty-sy):
    ans += 'U'
for _ in range(tx-sx):
    ans += 'R'
for _ in range(ty-sy):
    ans += 'D'
for _ in range(tx-sx+1):
    ans += 'L'
for _ in range(ty-sy+1):
    ans += 'U'
for _ in range(tx-sx+1):
    ans += 'R'
ans += 'D'
ans += 'R'
for _ in range(ty-sy+1):
    ans += 'D'
for _ in range(tx-sx+1):
    ans += 'L'
ans += 'U'
print(ans)

Submission status: Accepted

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


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

    for y in range(ty - sy):
        first.append('U')
        second.append('D')

    for x in range(tx - sx):
        first.append('R')
        second.append('L')

    third = ['L', 'U'] + first + ['R', 'D']
    fourth = ['R', 'D'] + second + ['L', 'U']

    print(''.join(map(str, first + second + third + fourth)))


if __name__ == '__main__':
    main()

Submission status: Accepted

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


def main():
    sx, sy, tx, ty = map(int, input().split())
    x_count = abs(tx - sx)
    y_count = abs(ty - sy)
    first = list()
    second = list()

    for y in range(y_count):
        first.append('U')

    for x in range(x_count):
        first.append('R')

    for y in range(y_count):
        second.append('D')

    for x in range(x_count):
        second.append('L')

    third = ['L', 'U'] + first + ['R', 'D']
    fourth = ['R', 'D'] + second + ['L', 'U']

    print(''.join(map(str, first + second + third + fourth)))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

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

ans = ""

for i in range(abs(ty - sy)):
    ans += 'U'

for i in range(abs(tx - sx)):
    ans += 'R'

for i in range(abs(ty - sy)):
    ans += 'D'

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

ans += 'L'

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

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

ans += 'D'
ans += 'R'

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

for i in range(abs(tx - sx) + 1):
    ans += 'L'

ans += 'U'

print(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):
    print("L", end="")

print("L", end="")
for _ in range(ty-sy):
    print("U", end="")
print("U", end="")
for _ in range(tx-sx):
    print("R", end="")
print("R", end="")
print("D", end="")

print("R", end="")
for _ in range(ty-sy):
    print("D", end="")
print("D", end="")
for _ in range(tx-sx):
    print("L", end="")
print("L", end="")
print("U", end="")

print()

Submission status: Accepted

Solution code:
import sys

def solve(sx, sy, tx, ty):
    # sA -> tA -> tB -> sB -> sC -> tC -> tD -> sD
    # ..+-------D.
    # ..|+---->AtC
    #   vA......B^
    #   DsB<----+|
    #    C-------+

    dx = tx - sx
    dy = ty - sy
    A = ((sx, sy+1), (tx-1, ty))
    B = ((tx, ty-1), (sx+1, sy))
    C = ((sx, sy-1), (tx+1, ty))
    D = ((tx, ty-1), (sx-1, sy))

    path = ''
    # A
    path += 'U' * dy
    path += 'R' * dx
    # B
    path += 'D' * dy
    path += 'L' * dx
    # C
    path += 'D'
    path += 'R' * (dx + 1)
    path += 'U' * (dy + 1)
    path += 'L'
    # D
    path += 'U'
    path += 'L' * (dx + 1)
    path += 'D' * (dy + 1)
    path += 'R'

    print(path)

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

X=tx-sx
Y=ty-sy

for i in range(X):
    print("R",end="")

for i in range(Y):
    print("U",end="")

for i in range(X):
    print("L",end="")

for i in range(Y+1):
    print("D",end="")

for i in range(X+1):
    print("R",end="")

for i in range(Y+1):
    print("U",end="")

print("L",end="")
print("U",end="")

for i in range(X+1):
    print("L",end="")

for i in range(Y+1):
    print("D",end="")

print("R",end="")

Submission status: Accepted

Solution code:
INF = 10**9+7

xy = list(map(int,input().split()))
ans =''

for i in range(xy[3]-xy[1]):
	ans += 'U'
for i in range(xy[2]-xy[0]):
	ans += 'R'
for i in range(xy[3]-xy[1]):
	ans += 'D'
for i in range(xy[2]-xy[0]+1):
	ans += 'L'
for i in range(xy[3]-xy[1]+1):
	ans += 'U'
for i in range(xy[2]-xy[0]+1):
	ans += 'R'
ans += 'DR'
for i in range(xy[3]-xy[1]+1):
	ans += 'D'
for i in range(xy[2]-xy[0]+1):
	ans += 'L'
ans+= 'U'
print(ans)

Submission status: Accepted

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

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 ("".join(ans))

Submission status: Accepted

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

dx, dy = tx-sx, ty-sy
u = 'U'*dy+'R'*dx+'D'*dy+'L'*(dx+1)+'U'*(dy+1)+'R'*(dx+1)+'DR'+'D'*(dy+1)+'L'*(dx+1)+'U'

print(u)

Submission status: Accepted

Solution code:
x,y,xx,yy=map(int,input().split())
x=xx-x
y=yy-y
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()))
dir_x = tx > sx
dir_y = ty > sy
space_x = abs(sx - tx)
space_y = abs(sy - ty)
if dir_x:
    if dir_y:
        dirset = 'RULDDRULULDR'
    else:
        dirset = 'RDLUURDLDLUR'
else:
    if dir_y:
        dirset = 'LURDDLURURDL'
    else:
        dirset = 'LDRUULDRDRUL'

for p in range(space_x):
    print(dirset[0],end='')    
for p in range(space_y):
    print(dirset[1],end='')
for p in range(space_x):
    print(dirset[2],end='')
for p in range(space_y):
    print(dirset[3],end='')
print(dirset[4],end='')
for p in range(space_x+1):
    print(dirset[5],end='')
for p in range(space_y+1):
    print(dirset[6],end='')
print(dirset[7],end='')
print(dirset[8],end='')
for p in range(space_x+1):
    print(dirset[9],end='')
for p in range(space_y+1):
    print(dirset[10],end='')
print(dirset[11],end='')

Submission status: Accepted

Solution code:
def rev(str):
    ans = ''
    for i in list(str):
        if i =='R':
            ans += 'L'
        elif i == 'L':
            ans += 'R'
        elif i =='U':
            ans += 'D'
        else:
            ans += 'U'
    return ans
def main():
    sx,sy,tx,ty = map(int,input().split(' '))
    ans_1 =''
    ans_2 = ''
    if sx-tx <0:
        ans_1 += 'R'*(tx-sx)
        ans_2 += 'L'
        mid = 'R'
    elif sx-tx >0:
        ans_1 += 'L'*(sx-tx)
        ans_2 += 'R'
        mid = 'L'
    if sy-ty <0:
        ans_1 += 'U'*(ty-sy)
        ans_2 += 'U'*(ty-sy+1)
        last = 'D'
    elif sy-ty >0:
        ans_1 += 'D'*(sy-ty)
        ans += 'D'*(sy-ty+1)
        last = 'D'
    ans_2 += mid*(abs(sx-tx)+1)+last
    ans = ans_1+rev(ans_1)+ans_2+rev(ans_2)
    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

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:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

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

  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'

  return ans

print(main())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# cms =  list("UDRL")
# mvs = [(0,1),(0,-1),(1,0),(-1,0)]

dx = (tx-sx)
dy = (ty-sy)
ans = ""
# 一回目 s -> t -> s
ans += ("U")*dy+("R")*dx+("D")*dy+("L")*dx
# 二回目 一旦左に行く s->t
ans += "L"
ans += "U"*(dy+1)
ans += "R"*(dx+1)
ans += "D"
# 二回目 t->s
ans += "R"
ans += "D"*(dy+1)
ans += "L"*(dx+1)
ans += "U"

print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = [int(i) for i in 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())

ux = (tx - sx)
uy = (ty - sy)
route = []

for i in range(ux):
    route.append('R')
for i in range(uy):
    route.append('U')
for i in range(ux):
    route.append('L')
for i in range(uy):
    route.append('D')
    
route.append('D')
for i in range(ux):
    route.append('R')
route.append('R')
route.append('U')
for i in range(uy):
    route.append('U')
route.append('L')
route.append('U')
for i in range(ux):
    route.append('L')
route.append('L')
route.append('D')
for i in range(uy):
    route.append('D')
route.append('R')

ans = ''

for i in route:
    ans += i
print(ans)

Submission status: Accepted

Solution code:
sx,sy,tx,ty = [int(x) for x in input().split()]
m1 = 'U'*(ty-sy)+'R'*(tx-sx)
m2 = 'D'*(ty-sy)+'L'*(tx-sx)
m3 = 'D'+'R'*(tx-sx+1)+'U'*(ty-sy+1)+'L'
m4 = 'U'+'L'*(tx-sx+1)+'D'*(ty-sy+1)+'R'
print(m1+m2+m3+m4)

Submission status: Accepted

Solution code:
import numpy as np
# 座標を入力
sx, sy, tx, ty = map(int, input().split())
S = np.array([sx, sy])
T = np.array([tx, ty])

# 2点の最短経路を返す関数を定義（左右移動優先かつ方向転換1回のみ） 
def shortest_path(start, end):
    if start[0] <= end[0]:
        lr_path = "R" * (end[0] - start[0])
    else:
        lr_path = "L" * (start[0] - end[0])
    if start[1] <= end[1]:
        ud_path = "U" * (end[1] - start[1])
    else:
        ud_path = "D" * (start[1] - end[1])
    return lr_path + ud_path

# 点Sから点Tまでの経路（1回目）
path_1 = shortest_path(S, T)
# 点Tから点Sまでの経路（1回目）
path_2 = shortest_path(T, S)
# 点Sから点Tまでの経路（2回目）
path_3 = "D" + shortest_path(S + np.array([0, -1]), T + np.array([1, 0])) + "L"
# 点Tから点Sまでの経路（2回目）
path_4 = "U" + shortest_path(T + np.array([0, 1]), S + np.array([-1, 0])) + "R"
# 全経路を出力
print(path_1 + path_2 + path_3 + path_4)

Submission status: Accepted

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

X = tx - sx
Y = ty - sy
go1 = ''
back1 = ''

for i in range(abs(X)):
  go1 += 'R'
  back1 += 'L'
for i in range(abs(Y)):
  go1 += 'U'
  back1 += 'D'

go2 = 'D'
back2 = 'U'

for i in range(go1.count('R')+1):
  go2 += 'R'
  back2 += 'L'
for i in range(go1.count('U')+1):
  go2 += 'U'
  back2 += 'D'

go2 += 'L'
back2 += 'R'

print(go1+back1+go2+back2)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
# ABC051C - Back and Forth
def main():
    sx, sy, tx, ty = list(map(int, input().rstrip().split()))
    X, Y = abs(sx - tx), abs(sy - ty)
    move = ""
    move += "U" * Y + "R" * X + "D" * Y + "L" * X
    move += "L" + "U" * (Y + 1) + "R" * (X + 1) + "D"
    move += "R" + "D" * (Y + 1) + "L" * (X + 1) + "U"
    print(move)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
x1,y1,x2,y2=map(int,input().split())
W,H=x2-x1,y2-y1
print(("R"*W)+("U"*H)+("L"*W)+("D"*H)+"D"+("R"*(W+1))+("U"*(H+1))+"LU"+("L"*(W+1))+("D"*(H+1))+"R")

Submission status: Accepted

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

y = ty - sy
x = tx - sx

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

Submission status: Accepted

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

Submission status: Accepted

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

path1 = "U" * (ty - sy) + "R" * (tx - sx)
path2 = "D" * (ty - sy) + "L" * (tx - sx)
path3 = "L" + "U" * (ty - sy + 1) + "R" * (tx - sx + 1) + "D"
path4 = "R" + "D" * (ty - sy + 1) + "L" * (tx - sx + 1) + "U"

print(path1 + path2 + path3 + path4)

Submission status: Accepted

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

dy = ty - sy
dx = tx - sx

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

Submission status: Accepted

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


def get_route(start_x, start_y, end_x, end_y):
    route = ''
    d_y = end_y - start_y
    dir = ''
    if d_y < 0:
        dir = 'D'
    else:
        dir = 'U'
    for i in range(abs(d_y)):
        route += dir

    d_x = end_x - start_x
    dir = ''
    if d_x < 0:
        dir = 'L'
    else:
        dir = 'R'
    for i in range(abs(d_x)):
        route += dir

    return route


ans = get_route(sx, sy, tx, ty)
ans += get_route(tx, ty, sx, sy)
ans += 'LU' + get_route(sx, sy, tx, ty) + 'RD'
ans += 'RD' + get_route(tx, ty, sx, sy) + 'LU'

print(ans)

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import bisect
from datetime import datetime as dt
import math

def gcd(a, b):
    return math.gcd(a, b)

def lcm(a, b):
    return a * b // gcd(a, b)

if __name__ == '__main__':
    a, b, c, d = map(int, input().split())
    ans = ''
    ans += 'R'*(c-a)
    ans += 'U'*(d-b)
    ans += 'L'*(c-a)
    ans += 'D'*(d-b)
    ans += 'D'
    ans += 'R'*(c-a+1)
    ans += 'U'*(d-b+1)
    ans += 'L'
    ans += 'U'
    ans += 'L'*(c-a+1)
    ans += 'D'*(d-b+1)
    ans += 'R' 
    print(ans)

Submission status: Accepted

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

# 1往復目
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):
    print("L",end='')

# 2往復目
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()