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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

len_x = tx - sx
len_y = ty - sy

ans = []
for _ in range(len_x):
    ans.append("R")
for _ in range(len_y):
    ans.append("U")
for _ in range(len_x):
    ans.append("L")
for _ in range(len_y):
    ans.append("D")
    
ans.append("D")
for _ in range(len_x + 1):
    ans.append("R")
for _ in range(len_y + 1):
    ans.append("U")
ans.append("L")
ans.append("U")
for _ in range(len_x + 1):
    ans.append("L")
for _ in range(len_y + 1):
    ans.append("D")
ans.append("R")

print("".join(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int,input().split())
ans = ''
u = 'U'*(ty-sy)
r = 'R'*(tx-sx)
d = 'D'*(ty-sy)
l = 'L'*(tx-sx+1)
u2 = 'U'*(ty-sy+1)
r2 = 'R'*(tx-sx+1)
d2 = 'D'
r3 = 'R'
d3 = 'D'*(ty-sy+1)
l2 = 'L'*(tx-sx+1)
print(u+r+d+l+u2+r2+d2+r3+d3+l2+'U')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
sx, sy, tx, ty = map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

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

print(ans)

Submission status: Accepted

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

def go():
    out = []
    x, y = sx, sy
    while y < ty:
        out.append('U'); y += 1
    while x < tx:
        out.append('R'); x += 1
    while y > sy:
        out.append('D'); y -= 1
    while x > sx:
        out.append('L'); x -= 1
    out.append('L'); x -= 1
    while y <= ty:
        out.append('U'); y += 1
    while x < tx:
        out.append('R'); x += 1
    out.append('D'); y -= 1
    out.append('R'); x += 1
    while y >= sy:
        out.append('D'); y -= 1
    while x > sx:
        out.append('L'); x -= 1
    out.append('U');
    return ''.join(out)

print(go())

Submission status: Accepted

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

ans = []

for x in range(tx-sx):
    ans.append('R')
for y in range(ty-sy):
    ans.append('U')
for x in range(tx-sx):
    ans.append('L')
for y in range(ty-sy):
    ans.append('D')
    
ans.append('D')

for x in range(tx-sx+1):
    ans.append('R')
for y in range(ty-sy+1):
    ans.append('U')
    
ans.append('L')
ans.append('U')

for x in range(tx-sx+1):
    ans.append('L')
for y in range(ty-sy+1):
    ans.append('D')
    
ans.append('R')
    
print(''.join(ans))

Submission status: Accepted

Solution code:
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    sx, sy, tx, ty = MII()
    x1 = tx-sx
    y1 = ty-sy
    go1 = 'U'*y1 + 'R'*x1
    bk1 = 'D'*y1 + 'L'*x1
    go2 = 'L'+'U'+go1+'R'+'D'
    bk2 = 'R'+'D'+bk1+'L'+'U'
    print(go1+bk1+go2+bk2)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
in1 = sys.stdin.readlines()

#in1 = ['-2 -2 1 1']

sx, sy, tx, ty = map(int, in1[0].split())

lx = tx - sx
ly = ty - sy

print('U'*ly+'R'*lx+'D'*ly+'L'*lx+'L'+'U'*(ly+1)+'R'*(lx+1)+'DR'+'D'*(ly+1)+'L'*(lx+1)+'U')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

a, b, c, d = map(int, sys.stdin.readline().split())

def main():
  dy, dx = d - b, c - a
  res = 'U' * dy + 'R' * (dx + 1) + 'D' * (dy + 1) + 'L' * (dx + 1)
  res += 'UL'
  res += 'U' * (dy + 1) + 'R' * (dx + 1) + 'D' * (dy + 1) + 'L' * dx
  print(res) 
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
A, B, C, D = map(int, input().split())

x = C-A
y = D-B
first = 'U'*y+'R'*x
second = 'D'+"L"*(x-1)+'D'*(y-1)+'L'
third = 'LU'+first+'RD'
last = 'RD'+second+'LU'

print(first+second+third+last)

Submission status: Accepted

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
import itertools
#from scipy.misc import comb

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

Submission status: Accepted

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

sx,sy,tx,ty=imn()

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

Submission status: Accepted

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


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

def main():
  sx,sy,tx,ty = readInts()
  h  =ty - sy
  w = tx-sx
  a = 'U' * h + 'R' * w
  b  = 'D' * h + 'L' * w
  print(a + b + 'LU' + a + 'RDRD' + b + 'LU')
if __name__ == '__main__':
  main()

Submission status: Accepted

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

w=abs(sx-tx)
h=abs(sy-ty)

ans=''

for _ in range(h):
    ans+="U"
    # print("U")

for _ in range(w+1):
    ans+="R"
    #print("R")

for _ in range(h+1):
    ans+="D"
    #print("D")

for _ in range(w+1):
    ans+="L"
    #print("L")

ans+="UL"

for _ in range(h+1):
    ans+="U"

for _ in range(w+1):
    ans+="R"

for _ in range(h+1):
    ans+="D"

for _ in range(w):
    ans+="L"

print(ans)

Submission status: Accepted

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

S = ""
for k in range(2):
    if k == 1:
        S += "L"
    for i in range(ty-sy+k):
        S += "U"
    for i in range(tx-sx+k):
        S += "R"
    if k == 1:
        S += "DR"
    for i in range(ty-sy+k):
        S += "D"
    for i in range(tx-sx+k):
        S += "L"
    if k == 1:
        S += "U"

print(S)

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

Submission status: Accepted

Solution code:
walklist=[]
a,b,c,d=map(int,input().split())
x_diff=c-a
y_diff=d-b
walklist.append("U"*y_diff)
walklist.append("R"*x_diff)
walklist.append("D"*y_diff)
walklist.append("L"*(x_diff+1))
walklist.append("U"*(y_diff+1))
walklist.append("R"*(x_diff+1))
walklist.append("D")
walklist.append("R")
walklist.append("D"*(y_diff+1))
walklist.append("L"*(x_diff+1))
walklist.append("U")
print("".join(walklist))

Submission status: Accepted

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

dx=tx-sx
dy=ty-sy

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

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

print(root)

Submission status: Accepted

Solution code:
ax,ay,bx,by = map(int,input().split())
path = []
y = int(by-ay)
x = int(bx-ax)
#１
for i in range(y):
    path.append('U')
for i in range(abs(x)):
    path.append('R')
for i in range(y):
    path.append('D')
for i in range(abs(x)):
    path.append('L')
#2
path.append('L')
for i in range(y+1):
    path.append('U')
for i in range(x+1):
    path.append('R')
path.append('D')
path.append('R')
for i in range(y+1):
    path.append('D')
for i in range(x+1):
    path.append('L')
path.append('U')
print(''.join(path))

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
s=[]
dis_x=abs(tx-sx)
dis_y=abs(ty-sy)
for i in range(dis_x):
  s.append('R')
for i in range(dis_y):
  s.append('U')
for i in range(dis_x):
  s.append('L')
for i in range(dis_y):
  s.append('D')
s.append('L')
for i in range(dis_y+1):
  s.append('U')
for i in range(dis_x+1):
  s.append('R')
s.append('D')
s.append('R')
for i in range(dis_y+1):
  s.append('D')
for i in range(dis_x+1):
  s.append('L')
s.append('U')

print(''.join(s))

Submission status: Accepted

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

r1 = 'R'*W + 'U'*H + 'L'*W + 'D'*H
r2 = 'D' + 'R'*(W+1) + 'U'*(H+1) + 'L' + 'U' + 'L'*(W+1) + 'D'*(H+1) +'R'
print(r1+r2)

Submission status: Accepted

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

Submission status: Accepted

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

res = []
for i in range(abs(ty - sy)):
    res.append("U")
for i in range(abs(tx - sx)):
    res.append("R")
for i in range(abs(sy - ty)):
    res.append("D")
for i in range(abs(tx - sx) + 1):
    res.append("L")
for i in range(abs(ty - sy) + 1):
    res.append("U")
for i in range(abs(tx - sx) + 1):
    res.append("R")
res.append("D")
res.append("R")
for i in range(abs(ty - sy) + 1):
    res.append("D")
for i in range(abs(tx - sx) + 1):
    res.append("L")
res.append("U")
print("".join(res))

Submission status: Accepted

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

y = ty - sy
x = tx - sx

u = "U" * y
r = "R" * x
d = "D" * y
l = "L" * x

offset1 = "LU"
offset2 = "RD"
print(u + r + d + l + offset1 + u + r + offset2 + offset2 + d + l + offset1)

Submission status: Accepted

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

dx, dy = tx - sx, ty - sy

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

print(path)

Submission status: Accepted

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

Submission status: Accepted

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

home = [sx,sy]
goal = [tx,ty]
point = [sx,sy]

ans_li = []

def move_to(start,end):
  while start!=end:
    if start[0]>end[0]:
      start[0]-=1
      ans_li.append('L')
    if start[0]<end[0]:
      start[0]+=1
      ans_li.append('R')
    if start[1]>end[1]:
      start[1]-=1
      ans_li.append('D')
    if start[1]<end[1]:
      start[1]+=1
      ans_li.append('U')

move_to(home,[sx,ty])
move_to([sx,ty],[tx,ty])
move_to(goal,[tx,sy])
move_to([tx,sy],[sx,sy])

ans_li.append('L')
move_to([sx-1,sy],[sx-1,ty+1])
move_to([sx-1,ty+1],[tx,ty+1])
ans_li.append('D')
ans_li.append('R')
move_to([tx+1,ty],[tx+1,sy-1])
move_to([tx+1,sy-1],[sx,sy-1])
ans_li.append('U')

print(''.join(ans_li))

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

Submission status: Accepted

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

go1 = ['U']*(ty-sy)+['R']*(tx-sx)

back1 = ['D']*(ty-sy)+['L']*(tx-sx)

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

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

ans = go1+back1+go2+back2

print(''.join(map(str,ans)))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

x = tx - sx
y = ty - sy

ans = ''

# s -> t, t -> s
ans += "U" * y
ans += "R" * x
ans += "D" * y
ans += "L" * x

# 1マス外側 s -> t, t ->s 
ans += "L"
ans += "U" * (y + 1)
ans += "R" * (x + 1)
ans += "D"

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

print(ans)

# dijkstraで解く
# 格子上の最短経路，障害なし，なのでまっすぐ行って帰るを繰り返す

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s_x, s_y, t_x, t_y = map(int, readline().split())
if s_x < 0 and t_x < 0:
    x = abs(s_x) - abs(t_x)
else:
    x = t_x - s_x
if s_y < 0 and t_y < 0:
    y = abs(s_y) - abs(t_y)
else:
    y = t_y - s_y
print('U' * y + 'R' * x + 'D' * y + 'L' * (x + 1) + '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())
way = []
way += ['U' for _ in range(ty-sy)]
way += ['R' for _ in range(tx-sx)]
way += ['D' for _ in range(ty-sy)]
way += ['L' for _ in range(tx-sx+1)]
way += ['U' for _ in range(ty-sy+1)]
way += ['R' for _ in range(tx-sx+1)]
way += ['D','R']
way += ['D' for _ in range(ty-sy+1)]
way += ['L' for _ in range(tx-sx+1)]
way += ['U']
print(''.join(way))

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

sx,sy,tx,ty=map(int,input().split())
anslst=""
anslst+="R"*(tx-sx)
anslst+="U"*(ty-sy)
anslst+="L"*(tx-sx)
anslst+="D"*(ty-sy)

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

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

print(anslst)

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
p=[sx,sy]
root=""
for i in range(ty-sy):
    p[1]=p[1]+1
    root="".join((root,"U"))
for i in range(tx-sx):
    p[0]=p[0]+1
    root="".join((root,"R"))
for i in range(ty-sy):
    p[1]=p[1]-1
    root="".join((root,"D"))
for i in range(tx-sx):
    p[0]=p[0]-1
    root="".join((root,"L"))

p[0]=p[0]-1
root = "".join((root, "L"))
for i in range(ty - sy+1):
    p[1] = p[1] + 1
    root = "".join((root, "U"))
for i in range(tx - sx+1):
    p[0] = p[0] + 1
    root = "".join((root, "R"))
p[1]=p[1]-1
root = "".join((root, "D"))
p[0]=p[0]+1
root = "".join((root, "R"))
for i in range(ty - sy+1):
    p[1] = p[1] + 1
    root = "".join((root, "D"))
for i in range(tx - sx+1):
    p[0] = p[0] + 1
    root = "".join((root, "L"))
p[1]=p[1]+1
root = "".join((root, "U"))
#UUURRRDDDLLLLUUUURRRRDRDDDDLLLLU
#UURRURRDDDLLDLLULUUURRURRDDDLLDL

print(root)

Submission status: Accepted

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

    for i in range(x):
        ans.append("R")
    for i in range(y):
        ans.append("U")
    ans.append("R")
    for i in range(y+1):
        ans.append("D")
    for i in range(x+1):
        ans.append("L")
    ans.append("U")

if x > 0 and y < 0:
    for i in range(-y):
        ans.append("D")
    for i in range(x):
        ans.append("R")
    ans.append("D")
    for i in range(x+1):
        ans.append("L")
    for i in range(-y+1):
        ans.append("U")
    ans.append("R")

    for i in range(x):
        ans.append("R")
    for i in range(-y):
        ans.append("D")
    ans.append("R")
    for i in range(-y+1):
        ans.append("U")
    for i in range(x+1):
        ans.append("L")
    ans.append("D")

if x < 0 and y > 0:
    for i in range(y):
        ans.append("U")
    for i in range(-x):
        ans.append("L")
    ans.append("U")
    for i in range(-x+1):
        ans.append("R")
    for i in range(y+1):
        ans.append("D")
    ans.append("L")

    for i in range(-x):
        ans.append("L")
    for i in range(y):
        ans.append("U")
    ans.append("L")
    for i in range(y+1):
        ans.append("D")
    for i in range(-x+1):
        ans.append("R")
    ans.append("U")

if x < 0 and y < 0:
    for i in range(-y):
        ans.append("D")
    for i in range(-x):
        ans.append("L")
    ans.append("D")
    for i in range(-x+1):
        ans.append("R")
    for i in range(-y+1):
        ans.append("U")
    ans.append("L")

    for i in range(-x):
        ans.append("L")
    for i in range(-y):
        ans.append("D")
    ans.append("L")
    for i in range(-y+1):
        ans.append("U")
    for i in range(-x+1):
        ans.append("R")
    ans.append("D")

if y==0:
    if x>0:
        for i in range(x):
            ans.append("R")
        ans.append("U")
        for i in range(x):
            ans.append("L")
        ans.append("D")

        ans.append("D")
        for i in range(x):
            ans.append("R")
        ans.append("U")
        ans.append("R")
        ans.append("D")
        ans.append("D")
        for i in range(x+2):
            ans.append("L")
        ans.append("U")
        ans.append("U")
        ans.append("R")
    if x<0:
        x = -x
        for i in range(x):
            ans.append("L")
        ans.append("U")
        for i in range(x):
            ans.append("R")
        ans.append("D")

        ans.append("D")
        for i in range(x):
            ans.append("L")
        ans.append("U")
        ans.append("L")
        ans.append("D")
        ans.append("D")
        for i in range(x+2):
            ans.append("R")
        ans.append("U")
        ans.append("U")
        ans.append("L")

if x==0:
    if y>0:
        for i in range(y):
            ans.append("U")
        ans.append("R")
        for i in range(y):
            ans.append("D")
        ans.append("L")

        ans.append("L")
        for i in range(y):
            ans.append("U")
        ans.append("R")
        ans.append("U")
        ans.append("L")
        ans.append("L")
        for i in range(y+2):
            ans.append("D")
        ans.append("R")
        ans.append("R")
        ans.append("U")
    if y<0:
        y = -y
        for i in range(y):
            ans.append("D")
        ans.append("R")
        for i in range(y):
            ans.append("U")
        ans.append("L")

        ans.append("L")
        for i in range(y):
            ans.append("D")
        ans.append("R")
        ans.append("D")
        ans.append("L")
        ans.append("L")
        for i in range(y+2):
            ans.append("U")
        ans.append("R")
        ans.append("R")
        ans.append("D")

output = "".join(ans)
print(output)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy

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

print(*ans, sep="")

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
print("U"*dy+"R"*dx+"D"*dy+"L"*dx,end="")
print("L"+"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().split())
x=tx-sx
y=ty-sy
print('U'*y+'R'*x+'D'*y+'L'*(x+1)+'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())
right = abs(tx - sx)
up = abs(ty - sy)
root = 'U'*up + 'R'*right
root_back = 'D'*up + 'L'*right
root2 = 'L' + 'U'*(up+1) + 'R'*(right+1) + 'D'
root_back2 = 'R' + 'D'*(up+1) + 'L'*(right+1) + 'U'
print(root+root_back+root2+root_back2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

dx = "R" * (tx - sx)
dy = "U" * (ty - sy)
ans = dx + dy

dx = "L" * (tx - sx)
dy = "D" * (ty - sy)
ans = ans + dx + dy

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

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

print(ans)

Submission status: Accepted

Solution code:
#coding: utf-8

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

ans = ""
dx = tx - sx
dy = ty - sy

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

print(ans)
# UURDDLLUUURRDRDDDLLU

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int,input().split())
ans = []
dx = tx-sx
dy = ty-sy
if dy>0:
    if dx>0:
        a = ['U','R','D','L']
    else:
        a = ['U','L','D','R']
else:
    if dx>0:
        a = ['D','R','U','L']
    else:
        a = ['D','L','U','R']
dx,dy = abs(dx),abs(dy)
ans.append(a[0]*dy)
ans.append(a[1]*dx)
ans.append(a[2]*dy)
ans.append(a[3]*(dx+1))
ans.append(a[0]*(dy+1))
ans.append(a[1]*(dx+1))
ans.append(a[2])
ans.append(a[1])
ans.append(a[2]*(dy+1))
ans.append(a[3]*(dx+1))
ans.append(a[0])
print(''.join(ans))

Submission status: Accepted

Solution code:
# coding: utf-8
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+1):
    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)