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=map(int,input().split())

dx=tx-sx
dy=ty-sy
d={0:'R', 1:'U', 2:'L', 3:'D'}
dirc=[dx,dy,dx,dy]

def path(sign,x,y,z,w):
  return d[sign+1]*abs(z-x) + d[sign+2]*abs(y-w)

s=''
s+='R'
s+=path(-1, sx+1, sy, tx, ty-1)
s+='UU'
s+=path(1, tx,ty+1,sx-1,sy)
s+='RD'
s+=path(-1, sx,sy-1,tx+1,ty)
s+='LL'
s+=path(1, tx-1,ty,sx,sy+1)
s+='D'
print(s)

Submission status: Accepted

Solution code:
def resolve():
    sx, sy, tx, ty = [int(i) for i in input().split()]
    x = tx - sx
    y = ty - sy
    print("U" * y, "R" * x, sep="", end="")
    print("D" * y, "L" * x, sep="", end="")
    print("L", "U" * y, "U", "R" * x, "RD", sep="", end="")
    print("R", "D" * y, "DL", "L" * x, "U", sep="", end="")
    print()

resolve()

Submission status: Accepted

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

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

# s to t 1回目
route_x = tx - sx
route_y = ty - sy
print('U' * route_y, end='') # ↑
print('R' * route_x, end='') # →

# t to s 1回目
print('D' * route_y, end='') # ↓
print('L' * route_x, end='') # ←

# s to t 2回目
print('L', end='') # ←
print('U' * (route_y + 1), end='') # ↑
print('R' * (route_x + 1), end='') # →
print('D', end='') # ↓

# t to s 2回目
print('R', end='') # →
print('D' * (route_y + 1), end='') # ↓
print('L' * (route_x + 1), end='') # ←
print('U', end='')

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    sx, sy, tx, ty = MI()

    ans = deque([])
    # path1
    ans.extend(['U']*abs(ty - sy))
    ans.extend(['R']*abs(tx - sx))

    # path2
    ans.extend(['D']*abs(ty - sy))
    ans.extend(['L']*abs(tx - sx))

    # path3
    ans.extend(['L'])
    ans.extend(['U']*(abs(ty - sy)+1))
    ans.extend(['R']*(abs(tx - sx)+1))
    ans.extend(['D'])

    # path4
    ans.extend(['R'])
    ans.extend(['D'] * (abs(ty - sy)+1))
    ans.extend(['L'] * (abs(tx - sx)+1))
    ans.extend(['U'])

    # print(ans)
    printlist(ans, '')


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    sx, sy, tx, ty = MI()

    ans = ''
    # path1
    ans += 'U' * abs(ty - sy) + 'R' * abs(tx - sx)

    # path2
    ans += 'D' * abs(ty - sy) + 'L' * abs(tx - sx)

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

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

    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    sx, sy, tx, ty = MI()

    ans = deque([])
    # path1
    ans.extend(['U']*abs(ty - sy))
    ans.extend(['R']*abs(tx - sx))

    # path2
    ans.extend(['D']*abs(ty - sy))
    ans.extend(['L']*abs(tx - sx))

    # path3
    ans.extend(['L'])
    ans.extend(['U']*(abs(ty - sy)+1))
    ans.extend(['R']*(abs(tx - sx)+1))
    ans.extend(['D'])

    # path4
    ans.extend(['R'])
    ans.extend(['D'] * (abs(ty - sy)+1))
    ans.extend(['L'] * (abs(tx - sx)+1))
    ans.extend(['U'])

    # print(ans)
    printlist(ans, '')


if __name__ == '__main__':
    solve()

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+1)+'U'*(ty-sy+1)+'R'*(tx-sx+1)+'D'+'R'+'D'*(ty-sy+1)+'L'*(tx-sx+1)+'U')

Submission status: Accepted

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

s = ''
for _ in range(ty - sy):
    s += 'U'

for _ in range(tx - sx):
    s += 'R'

for _ in range(ty - sy):
    s += 'D'

for _ in range(tx - sx):
    s += 'L'

s += 'L'

for _ in range(ty - sy + 1):
    s += 'U'

for _ in range(tx - sx + 1):
    s += 'R'

s += 'DR'

for _ in range(ty - sy + 1):
    s += 'D'

for _ in range(tx - sx + 1):
    s += 'L'

s += 'U'

print(s)

Submission status: Accepted

Solution code:
sx,sy,gx,gy = (int(x) for x in input().split())
ans = ''
if sx < gx and sy < gy:
  ans += 'R'*(gx-sx) + 'U'*((gy-sy)+1) + 'L'*((gx-sx)+1) + 'D'*((gy-sy)+1) + 'R'
  ans += 'D' + 'R'*((gx-sx)+1) + 'U'*((gy-sy)+1) + 'L'*((gx-sx)+1) + 'D'*(gy-sy)
elif sx < gx and sy > gy:
  ans += 'R'*(gx-sx) + 'U'*((gy-sy)+1) + 'L'*((gx-sx)+1) + 'D'*((gy-sy)+1) + 'R'
print (ans)

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy
d1 = ['U']*dy + ['R']*dx
d2 = ['D']*dy + ['L']*dx
d3 = ['L'] + ['U']*(dy+1) + ['R']*(dx+1) + ['D']
d4 = ['R'] + ['D']*(dy+1) + ['L']*(dx+1) + ['U']

print(''.join(d1+d2+d3+d4))

Submission status: Accepted

Solution code:
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
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())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int,input().split()) #n:頂点数　m:辺の数
ans = []
#(sx, sy) to (tx, ty)
for i in range(tx - sx):
  ans.append("R")
for i in range(ty - sy):
  ans.append("U")
#reverse
for i in range(tx - sx):
  ans.append("L")
for i in range(ty - sy):
  ans.append("D")
#(sx, sy) to (sx, sy - 1) to (tx + 1, sy - 1) 
#to (tx + 1, ty) to (tx, ty)
ans.append("D")
for i in range(tx - sx + 1):
  ans.append("R")
for i in range(ty - sy + 1):
  ans.append("U")
ans.append("L")
#reverse
ans.append("U")
for i in range(tx - sx + 1):
  ans.append("L")
for i in range(ty - sy + 1):
  ans.append("D")
ans.append("R")

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    x1, y1, x2, y2 = in_nn()

    ans = 'R' * (x2 - x1) + 'U' * (y2 - y1)
    ans += 'L' * (x2 - x1) + 'D' * (y2 - y1)
    ans += 'L'
    ans += 'U' * (y2 - y1 + 1) + 'R' * (x2 - x1 + 1)
    ans += 'D'
    ans += 'R'
    ans += 'D' * (y2 - y1 + 1) + 'L' * (x2 - x1 + 1)
    ans += 'U'

    print(ans)


if __name__ == '__main__':
    main()

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

Submission status: Accepted

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

if dx == 0:
    if dy > 0:
        d1 = "U"
        d2 = "D"
    else:
        d1 = "D"
        d2 = "U"
    dy = abs(dy)
    ans = d1 * dy
    ans += "R" + d2 * dy + "L"
    ans += "L" + d1 * dy + "R"
    ans += d1 + "RR" + d2 * (dy + 2) + "LL" + d1
    print(ans)
    
elif dy == 0:
    if dx > 0:
        d1 = "R"
        d2 = "L"
    else:
        d1 = "L"
        d2 = "R"
    dx = abs(dx)
    ans = d1 * dx
    ans += "U" + d2 * dx + "D"
    ans += "D" + d1 * dx + "U"
    ans += d1 + "UU" + d2 * (dx + 2) + "DD" + d1
    print(ans)

else:
    if dy > 0:
        d1 = "U"
        d2 = "D"
    else:
        d1 = "D"
        d2 = "U"
    if dx > 0:
        d3 = "R"
        d4 = "L"
    else:
        d3 = "L"
        d4 = "R"
    dx = abs(dx)
    dy = abs(dy)
    ans = d1 * dy + d3 * dx
    ans += d2 * dy + d4 * dx
    ans += d4 + d1 * (dy + 1) + d3 * (dx + 1) + d2
    ans += d3 + d2 * (dy + 1) + d4 * (dx + 1) + d1
    print(ans)

Submission status: Accepted

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


def solve(sx: int, sy: int, tx: int, ty: int):
    ans = []
    ans.append("R"*(tx-sx))
    ans.append("U"*(ty-sy))
    ans.append("L"*(tx-sx))
    ans.append("D"*(ty-sy+1))
    ans.append("R"*(tx-sx+1))
    ans.append("U"*(ty-sy+1))
    ans.append("L")
    ans.append("U")
    ans.append("L"*(tx-sx+1))
    ans.append("D"*(ty-sy+1))
    ans.append("R")
    return "".join(ans)

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
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
    print(solve(sx, sy, tx, ty))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split())
x=c-a
y=d-b
ans=[]
for i in range(y):
    ans.append("U")
for i in range(x):
    ans.append("R")
for i in range(y):
    ans.append("D")
for i in range(x):
    ans.append("L")
ans.append("L")
for i in range(y+1):
    ans.append("U")
for i in range(x+1):
    ans.append("R")
ans.append("D")
ans.append("R")
for i in range(y+1):
    ans.append("D")
for i in range(x+1):
    ans.append("L")
ans.append("U")

print("".join(ans))

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
sx,sy,gx,gy=map(int,input().split())
s,t,u,v='','','DR','UL'
for i in range(gx-sx):
  s+='R'
  t+='L'
  u+='R'
  v+='L'
u+='U'
v+='D'
for i in range(gy-sy):
  s+='U'
  t+='D'
  u+='U'
  v+='D'
print(s+t+u+'L'+v+'R')

Submission status: Accepted

Solution code:
sx,sy,gx,gy=map(int,input().split())
s=''
t=''
for i in range(gx-sx):
  s+='R'
  t+='L'
for i in range(gy-sy):
  s+='U'
  t+='D'
s+=t
s+='D'
t='U'
for i in range(gx-sx+1):
  s+='R'
  t+='L'
for i in range(gy-sy+1):
  s+='U'
  t+='D'
s+='L'+t+'R'
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

W = abs(sx-tx)
H = abs(sy-ty)
ans = ""

for i in range(W):
    ans += "R"
for i in range(H+1):
    ans += "U"
for i in range(W+1):
    ans += "L"
for i in range(H+1):
    ans += "D"
ans += "R"

for i in range(H):
    ans += "U"
for i in range(W+1):
    ans += "R"
for i in range(H+1):
    ans += "D"
for i in range(W+1):
    ans += "L"
ans += "U"

print(ans)

Submission status: Accepted

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

countx=tx-sx
county=ty-sy

ans=[]
for i in range(county):
    ans.append("U")
for i in range(countx):
    ans.append("R")

for i in range(county):
    ans.append("D")
for i in range(countx):
    ans.append("L")

ans.append("L")

for i in range(county+1):
    ans.append("U")
for i in range(countx+1):
    ans.append("R")
ans.append("D")

ans.append("R")

for i in range(county+1):
    ans.append("D")
for i in range(countx+1):
    ans.append("L")

ans.append("U")

Z=[str(a) for a in ans]
Z="".join(Z)
print(Z)

Submission status: Accepted

Solution code:
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache
from numba import jit

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	sx, sy, tx, ty = LI()
	print("R"*(tx-sx)+"U"*(ty-sy)+"L"*(tx-sx)+"D"*(ty-sy+1)+"R"*(tx-sx+1)+"U"*(ty-sy+1)+"L"+"U"+"L"*(tx-sx+1)+"D"*(ty-sy+1)+"R")



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int, open(0).read().split())
dx = tx - sx
dy = ty - sy
ans = ['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(ans))

Submission status: Accepted

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

sx,sy,tx,ty = list(map(int,input().split()))
right = tx - sx
up = ty - sy

go1 = 'R'*right + 'U'*up
back1 =""
for i in range(len(go1)):
    if go1[i] == 'R':
        back1 += 'L'
    elif go1[i] == 'U':
        back1 += 'D'
    elif go1[i] == 'L':
        back1 += 'R'
    elif go1[i] == 'D':
        back1 += 'U'
        
go2 = 'D' + 'R'*(right+1)+'U'*(up+1)+'L'

back2 =""
for i in range(len(go2)):
    if go2[i] == 'R':
        back2 += 'L'
    elif go2[i] == 'U':
        back2 += 'D'
    elif go2[i] == 'L':
        back2 += 'R'
    elif go2[i] == 'D':
        back2 += 'U'

print(go1+back1+go2+back2)

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def calcTwoPointDistance(x1, y1, x2, y2):
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5


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

    sx, sy, tx, ty = il()

    move = []
    for _ in range(sy, ty):
        move.append('U')
    for _ in range(sx, tx):
        move.append('R')
    for _ in range(sy, ty):
        move.append('D')
    for _ in range(sx, tx):
        move.append('L')
    move.append('L')

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

    print(*move, sep='')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

def main(sx,sy,tx,ty):
    ans=''
    ans=ans+'U'*(ty-sy)
    ans=ans+'R'*(tx-sx+1)
    ans=ans+'D'*(ty-sy+1)
    ans=ans+'L'*(tx-sx+1)
    ans=ans+'U'+'L'
    ans=ans+'U'*(ty-sy+1)
    ans=ans+'R'*(tx-sx+1)
    ans=ans+'D'*(ty-sy+1)
    ans=ans+'L'*(tx-sx)
    return ans

if __name__=='__main__':
    sx,sy,tx,ty=readinput()
    ans=main(sx,sy,tx,ty)
    print(ans)

Submission status: Accepted

Solution code:
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
   CCC
   CAtD
   CABD
   CsBD
    DDD

    UUR
    DDL
    LUUURRD
    RDDDLLU

    """
    sx, sy, tx, ty = read_ints()
    return 'U'*(ty-sy)+'R'*(tx-sx)+'D'*(ty-sy)+'L'*(tx-sx)+'L'+'U'*(ty-sy+1)+'R'*(tx-sx+1)+'D'+'R'+'D'*(ty-sy+1)+'L'*(tx-sx+1)+'U'


if __name__ == '__main__':
    print(solve())

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# t -> s - > t -> s
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

ans = []
for i in range(dx):
    ans.append("R")

for j in range(dy):
    ans.append("U")

for i in range(dx):
    ans.append("L")

for j in range(dy):
    ans.append("D")

ans.append("D")

for i in range(dx + 1):
    ans.append("R")

for j in range(dy + 1):
    ans.append("U")

ans.append("L")

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

for j in range(dy + 1):
    ans.append("D")

ans.append("R")

print("".join(ans))

Submission status: Accepted

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

dx = tx-sx
dy = ty-sy
res =''
#1回目
for _ in range(dx): res += 'R'
for _ in range(dy): res += 'U'
for _ in range(dx): res += 'L'
for _ in range(dy): res += 'D'
#2回目
res += 'D'
for _ in range(dx+1): res += 'R'
for _ in range(dy+1): res += 'U'
res += "L"
res += "U"
for _ in range(dx+1): res += 'L'
for _ in range(dy+1): res += 'D'
res += 'R'
print(res)

Submission status: Accepted

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

hrz=tx-sx
vrt=ty-sy

a="U"*vrt
b="R"*hrz
c="D"*vrt
d="L"*hrz
ans1=a+b+c+d
a2=a+"U"
b2=b+"R"
c2=c+"D"
d2=d+"L"
ans2="L"+a2+b2+"DR"+c2+d2+"U"
print(ans1+ans2)

Submission status: Accepted

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

p1 = 'U' * (ty - sy) + 'R' * (tx - sx)
p2 = 'U' + 'L' * (tx - sx + 1) + 'D' * (ty - sy + 1) + 'R'
p3 = p1[::-1]
p4 = p2[::-1]

print(p1 + p2 + p3 + p4)

Submission status: Accepted

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

dx=tx-sx
dy=ty-sy

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x,y,X,Y=map(int,input().split())
a=X-x
b=Y-y
cnt=0
new_cnt=0
l=[]
L=[]
for i in range(a):
  l.append('R')
  cnt+=1

for i in range(b):
  l.append('U')
  new_cnt+=1

for i in l:
  if i=='R':
    l.append('L')
  elif i=='U':
    l.append('D')

l.append('D')
L.append('D')

for i in range(cnt+1):
  l.append('R')
  L.append('R')
  
for i in range(new_cnt+1):
  l.append('U')
  L.append('U')
l.append('L')
L.append('L')
l.append('U')
for i in L:
  if i=='R':
    l.append('L')
  elif i=='U':
    l.append('D')
l.append('R')

print(('').join(l))

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
ans=""
d=(tx-sx)+(ty-sy)#sとtの距離
#1週目　最短距離
for i in range(2*d):
    if i<=(tx-sx)-1:
        ans+="R"
    elif i<=d-1:
        ans+="U"
    elif i<=(d-1)+(tx-sx):
        ans+="L"
    else:
        ans+="D"
#print(ans)
#2週目 外周
for j in range(2*(d+4)):
    if j==0:
        ans+="D"
    elif j<=(tx-sx)+2-1:
        ans+="R"
    elif j<=(d+4)-1-1:
        ans+="U"
    elif j<=(d+4)-1:
        ans+="L"
    elif j<=(d+4)-1+1:
        ans+="U"
    elif j<=(d+4)-1+1+(tx-sx+1):
        ans+="L"
    elif j<=2*(d+4)-1-1:
        ans+="D"
    else:
        ans+="R"
print(ans)

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

Submission status: Accepted

Solution code:
import sys
#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')
from math import *


def main():
	a,b,c,d=MI()
	c-=a
	d-=b
	
	s="URDLLURDRDLU"
	li=[d,c,d,c,1,d+1,c+1,1,1,d+1,c+1,1]
	
	t=""
	for i in range(len(s)):
		t+=s[i]*li[i]
	print(t)
	




	

if __name__=="__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
coordinates = list(map(int,input().split()))
s = []
t = []

for i in range(len(coordinates)):
    if i < 2:
        s.append(coordinates[i])
    else:
        t.append(coordinates[i])

# print(s)
# print(t)

dx = t[0] - s[0]
dy = t[1] - s[1]

route = ""

# print("dx: ", dx)
# print("dy: ", dy)

# 経路パターン１
# 行き
for i in range(dx):
    route += "R"
for i in range(dy):
    route += "U"

# 帰り
for i in range(dx):
    route += "L"
for i in range(dy):
    route += "D"

# 経路パターン２（パターン１の外側を通る）
# 行き
route += "D"

for i in range(dx+1):
    route += "R"
for j in range(dy+1):
    route += "U"

route += "L"
route += "U"

for i in range(dx+1):
    route += "L"
for i in range(dy+1):
    route += "D"

route += "R"


# 解答出力
print(route)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

sx, sy, tx, ty = mapint()
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())
mx = tx - sx
my = ty - sy
print("U"*my+"R"*mx+"D"*my+"L"*mx+"L"+"U"*(my+1)+"R"*(mx+1)+"DR"+"D"*(my+1)+"L"*(mx+1)+"U")