Problem:


Score : 300 points

Problem Statement

Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.

Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.

Here, both the x- and y-coordinates before and after each movement must be integers.

He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).

Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).

Under this condition, find a shortest path for him.  

Constraints

-1000 ≤ sx < tx ≤ 1000 

-1000 ≤ sy < ty ≤ 1000 

sx,sy,tx and ty are integers.

Input

The input is given from Standard Input in the following format:

sx sy tx ty

Output

Print a string S that represents a shortest path for Dolphin.

The i-th character in S should correspond to his i-th movement.

The directions of the movements should be indicated by the following characters:  

U: Up

D: Down

L: Left

R: Right

If there exist multiple shortest paths under the condition, print any of them.

Sample Input 1

0 0 1 2

Sample Output 1

UURDDLLUUURRDRDDDLLU

One possible shortest path is:

Going from (sx,sy) to (tx,ty) for the first time: (0,0) → (0,1) → (0,2) → (1,2)

Going from (tx,ty) to (sx,sy) for the first time: (1,2) → (1,1) → (1,0) → (0,0)

Going from (sx,sy) to (tx,ty) for the second time: (0,0) → (-1,0) → (-1,1) → (-1,2) → (-1,3) → (0,3) → (1,3) → (1,2)

Going from (tx,ty) to (sx,sy) for the second time: (1,2) → (2,2) → (2,1) → (2,0) → (2,-1) → (1,-1) → (0,-1) → (0,0)

Sample Input 2

-2 -2 1 1

Sample Output 2

UURRURRDDDLLDLLULUUURRURRDDDLLDL



Sample input:
0 0 1 2


Sample output:
UURDDLLUUURRDRDDDLLU

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    sx, sy, tx, ty = LI()
    right = (tx - sx)
    up = (ty - sy)
    p1 = 'R' * right + 'U' * up
    p2 = 'L' * right + 'D' * up
    p3 = 'D' + 'R' * (right + 1) + 'U' * (up + 1) + 'L'
    p4 = 'U' + 'L' * (right + 1) + 'D' * (up + 1) + 'R'
    print(p1+p2+p3+p4)
main()

Submission status: Accepted

Solution code:
import sys
bbn=1000000007
	
#+++++

		
def main():
	sx,sy,tx,ty = map(int, input().split())
	cx=tx-sx
	cy=ty-sy
	
	u='U'
	d='D'
	l='L'
	r='R'
	
	ret=''
	ret+=u*cy
	ret+=r*cx
	ret+=d*cy
	ret+=l*(cx+1)
	ret+=u*(cy+1)
	ret+=r*(cx+1)
	ret+=d
	ret+=r
	ret+=d*(cy+1)
	ret+=l*(cx+1)
	ret+=u
	
	
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

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

dx, dy = tx-sx, ty-sy

path1 = 'U'*dy + 'R'*dx
path2 = 'D'*dy + 'L'*dx
path3 = 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D'
paht4 = 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'

ans = path1 + path2 + path3 + paht4
print(ans)

Submission status: Accepted

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

dx, dy = tx-sx, 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 += 'DR'
ans += 'D'*(dy+1)
ans += 'L'*(dx+1)
ans += 'U'

print(ans)

Submission status: Accepted

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

X = int(Tx - Sx)
Y = int(Ty - Sy)
#S-T-S-T-Sy

z = '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(z)

Submission status: Accepted

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

go = ""
back = ""

if sx <= tx:
    for i in range(tx-sx):
        go += "R"
        back += "L"
else:
    for i in range(sx-tx):
        go += "L"
        back += "R"
        
if sy <= ty:
    for i in range(ty-sy):
        go += "U"
        back += "D"
else:
    for i in range(ty-sy):
        go += "D"
        back += "U"

go_2nd = ""
back_2nd = ""

if sx <= tx:
    if sy <= ty:
        go_2nd += "D"
        go_2nd += "R"
        go_2nd += go
        go_2nd += "U"
        go_2nd += "L"
        back_2nd += "U"
        back_2nd += "L"
        back_2nd += back
        back_2nd += "D"
        back_2nd += "R"
    else:
        go_2nd += "U"
        go_2nd += "R"
        go_2nd += go
        go_2nd += "D"
        go_2nd += "L"
        back_2nd += "D"
        back_2nd += "L"
        back_2nd += back
        back_2nd += "U"
        back_2nd += "R"
else:
    if sy <= ty:
        go_2nd += "D"
        go_2nd += "L"
        go_2nd += go
        go_2nd += "U"
        go_2nd += "R"
        back_2nd += "U"
        back_2nd += "R"
        back_2nd += back
        back_2nd += "D"
        back_2nd += "L"
    else:
        go_2nd += "U"
        go_2nd += "L"
        go_2nd += go
        go_2nd += "D"
        go_2nd += "R"
        back_2nd += "D"
        back_2nd += "R"
        back_2nd += back
        back_2nd += "U"
        back_2nd += "L"


print(go + back + go_2nd + back_2nd)

Submission status: Accepted

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

ans = ''

ans +='R'*A + 'U'*B
ans +='L'*A + 'D'*B
ans +='L'+'U'*B+'U'+'R'*A +'R'+'D'
ans +='R'+'D'*B+'D'+'L'*A +'L'+'U'
print(ans)
# print('UURDDLLUUURRDRDDDLLU')

Submission status: Accepted

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

def forward(x, y, tx, ty):
   while y < ty:
      print('U', end='')
      y += 1
   while x < tx:
      print('R', end='')
      x += 1
   return()

def backward(x, y, sx, sy):
   while y > sy:
      print('D', end='')
      y -= 1
   while x > sx:
      print('L', end='')
      x -= 1
   return()

forward(sx, sy, tx, ty)
backward(tx, ty, sx, sy)

print('L', end='')
forward(sx-1, sy, tx, ty+1)
print('DR', end='')
backward(tx+1, ty, sx, sy-1)
print('U')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sx,sy,tx,ty=map(int,input().split())
ans=""
for i in range(ty-sy):
    ans+="U"
for i in range(tx-sx):
    ans+="R"
for i in range(ty-sy):
    ans+="D"
for i in range(tx-sx):
    ans+="L"
ans+="L"
for i in range(ty-sy+1):
    ans+="U"
for i in range(tx-sx+1):
    ans+="R"
ans+="DR"
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())
dx=tx-sx
dy=ty-sy
ans=""
ans+="R"*dx+"U"*dy
ans+="R"+"D"*(dy+1)+"L"*(dx+1)+"U"
ans+="U"*dy+"R"*dx
ans+="U"+"L"*(dx+1)+"D"*(dy+1)+"R"
print(ans)

Submission status: Accepted

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

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

s = ''

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

s = s + 'L'

for i in range(ty - sy + 1):
    s = s + 'U'
for i in range(tx - sx + 1):
    s = s + 'R'

s = s + 'DR'

for i in range(ty - sy + 1):
    s = s + 'D'
for i in range(tx - sx + 1):
    s = s + 'L'

s = s + 'U'

print(s)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
path = ''
for _ in range(tx - sx):
  path += 'R'
for _ in range(ty - sy):
  path += 'U'
for _ in range(tx - sx):
  path += 'L'
for _ in range(ty - sy):
  path += 'D'

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

print(path)

Submission status: Accepted

Solution code:
#ABC051C
x1,y1,x2,y2=map(int,input().split())
for i in range(y2-y1):
    print("U",end="")
for i in range(x2-x1):
    print("R",end="")
for i in range(y2-y1):
    print("D",end="")
for i in range(x2-x1):
    print("L",end="")
print("L",end="")
for i in range(y2-y1):
    print("U",end="")
print("U",end="")
for i in range(x2-x1):
    print("R",end="")
print("RDR",end="")
for i in range(y2-y1):
    print("D",end="")
print("DL",end="")
for i in range(x2-x1):
    print("L",end="")
print("U",end="")

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:
SX, SY, TX, TY = [int(n) for n in input().split()]

def main():
    xd = TX - SX
    yd = TY - SY
    first = ['R' * xd, 'U' * yd, 'L' * xd, 'D' * yd]
    second = ['D', 'R' * (xd + 1), 'U' * (yd + 1), 'L', 'U', 'L' * (xd + 1), 'D' * (yd + 1), 'R']

    ans = first + second
    print(''.join(ans))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

x=tx-sx
y=ty-sy


n1="U"*y +"R"*x+"D"*y+"L"*x
n2="L"+"U"*(y+1)+"R"*(x+1)+"D"
n3="R"+"D"*(y+1)+"L"*(x+1)+"U"
print(n1+n2+n3)

Submission status: Accepted

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

v1 = tx - sx
if v1 >= 0:
	sv0 = "R"
	sv1 = "L"
	s1 = "R" * v1
	s3 = "L" * v1
else:
	sv0 = "L"
	sv1 = "R"
	s1 = "L" * v1
	s3 = "R" * v1

v2 = ty - sy

if v2 >= 0:
	sh0 = "U"
	sh1 = "D"
	s2 = "U" * v2
	s4 = "D" * v2
else:
	sh0 = "D"
	sh1 = "U"
	s2 = "D" * v2
	s4 = "U" * v2


print(s1 + s2 + s3 + s4 + sh1 + sv0 + s1 + s2 + sh0 + sv1 + sh0 + sv1 + s3 + s4 + sh1 + sv0)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx-sx, ty-sy
ans = "UD"[dy<0]*dy + "RL"[dx<0]*dx + "UD"[dy>0]*dy
dx += 1;dy += 1
print(ans + "RL"[dx>0]*dx + "UD"[dy<0]*dy + "RL"[dx<0]*dx + "UD"[dy>0] + "RL"[dx<0] + "UD"[dy>0]*dy + "RL"[dx>0]*dx + "UD"[dy<0])

Submission status: Accepted

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

sx, sy, tx, ty = MAP()

x = tx - sx
y = ty - sy

# 進行方向の確定
ans = ''
if x >= 0:
    x1 = 'R'
    x2 = 'L'
else:
    x1 = 'L'
    x2 = 'R'
if y >= 0:
    y1 = 'U'
    y2 = 'D'
else:
    y1 = 'D'
    y2 = 'U'

# 1周目
ans += x1 * x
ans += y1 * y
ans += x2 * x
ans += y2 * y

# 2周目(ひと回り外側を通る)
ans += y2
ans += x1 * (x+1)
ans += y1 * (y+1)
ans += x2
ans += y1
ans += x2 * (x+1)
ans += y2 * (y+1)
ans += x1

print(ans)

Submission status: Accepted

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

print((d-b)*"U"+(c-a)*"R"+(d-b)*"D"+(c-a+1)*"L"+(d-b+1)*"U"+(c-a+1)*"R"+"DR"+(d-b+1)*"D"+(c-a+1)*"L"+"U")

Submission status: Accepted

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

u = "U" * (ty - sy)
d = "D" * (ty - sy)
r = "R" * (tx - sx)
l = "L" * (tx - sx)

s1 = u + r 
s2 = d + l
s3 = "LU" + s1 + "RD"
s4 = "RD" + s2 + "LU"
print(s1 + s2 + s3 + s4)

Submission status: Accepted

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

Submission status: Accepted

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

lenx = tx - sx
leny = ty - sy

for i in range(leny):
  keika.append('U')
for i in range(lenx):
  keika.append('R')
for i in range(leny):
  keika.append('D')
for i in range(lenx):
  keika.append('L')

keika.append('L')
for i in range(leny+1):
  keika.append('U')
for i in range(lenx+1):
  keika.append('R')
keika.append('D')
keika.append('R')
for i in range(leny+1):
  keika.append('D')
for i in range(lenx+1):
  keika.append('L')
keika.append('U')
print(''.join(keika))

Submission status: Accepted

Solution code:
N = list(map(int,input().split()))
for i in range(len(N)):
	N[i]+=1000
direction = ["U","L","D","R"]
sub_ans1=[]
sub_ans2=[]
sub_ans1 += ["U"]*(N[3]-N[1])
sub_ans1 += ["R"]*(N[2]-N[0])
#print(sub_ans1)

for i in range(len(sub_ans1)):
	sub_ans1 += direction[direction.index(sub_ans1[i])-2]

#print(sub_ans1)
sub_ans2 += ["L"]*1
sub_ans2 += ["U"]*(N[3]-N[1]+1)
sub_ans2 += ["R"]*(N[2]-N[0]+1)
sub_ans2 += ["D"]*1
#print(sub_ans2)
for i in range(len(sub_ans2)):
	sub_ans2 += direction[direction.index(sub_ans2[i])-2]
#print(sub_ans2)

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

def main():
    sx,sy,tx,ty = map(int,input().split())
    dx = tx-sx
    dy = 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)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ans = ""
#first
for i in range(up_num):
    ans += "U"
for i in range(right_num):
    ans += "R"
for i in range(up_num):
    ans += "D"
for i in range(right_num):
    ans += "L"
ans += "L"
for i in range(up_num):
    ans += "U"
ans += "UR"
for i in range(right_num):
    ans += "R"
ans += "DRD"
for i in range(up_num):
    ans += "D"
for i in range(right_num):
    ans += "L"
ans += "LU"

print(ans)

Submission status: Accepted

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

dif_x = tx - sx
dif_y = ty - sy

route_one_forward = 'U'*dif_y + 'R'*dif_x
route_two_back = 'D'*dif_y + 'L'*dif_x
route_three_forward = 'L' + 'U'*(dif_y + 1) + 'R'*(dif_x + 1) + 'D'
route_four_back = 'R' + 'D'*(dif_y + 1) + 'L'*(dif_x + 1) + 'U'

route_all = route_one_forward + route_two_back + route_three_forward + route_four_back
print(route_all)

Submission status: Accepted

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

sx, sy, gx,gy = map(int, input().split())



Y = abs(gy - sy)
X = abs(gx - sx)



output = ""
output += "U"*abs(Y)
output += "R"*abs(X)
output += "D"*abs(Y)
output += "L"*abs(X)

output += "L"

output += "U"*(abs(Y)+1)
output += "R"*(abs(X)+1)

output += "DR"

output += "D"*(abs(Y)+1)
output += "L"*(abs(X)+1)

output += "U"
print(output)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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:
# C版からの移植

sx, sy, tx, ty = map(int,input().split())
dx = tx - sx
dy = ty - sy
ans = ""

# 4点を結ぶ長方形：最短経路
for _ in range(dy):
    ans += "U"
for _ in range(dx):
    ans += "R"
for _ in range(dy):
    ans += "D"
for _ in range(dx):
    ans += "L"

# 上記の１まわり外側
ans += "L";
for _ in range(dy + 1):
    ans += "U"
for _ in range(dx + 1):
    ans += "R"
ans += "D";
ans += "R";
for _ in range(dy + 1):
    ans += "D"
for _ in range(dx + 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
ans = ""
ans += "U"*y + "R"*x # s -> t
ans += "D"*y + "L"*x # t -> s
# 2週目
ans += "L"+"U"*(y+1) + "R"*(x+1)+"D" # s -> t
ans += "R"+"D"*(y+1) + "L"*(x+1)+"U" # t -> s
print(ans)

Submission status: Accepted

Solution code:
# ABC051 C - Back and Forth
sx,sy,tx,ty = map(int, input().split())
x=-sx
y=-sy
sx+=x
sy+=y
tx+=x
ty+=y
tx=abs(tx)
ty=abs(ty)

ans=[]
ans+=['U']*ty
ans+=['R']*tx
ans+=['D']*ty
ans+=['L']*tx
ans+=['L']
ans+=['U']*(ty+1)
ans+=['R']*(tx+1)
ans+=['D']
ans+=['R']
ans+=['D']*(ty+1)
ans+=['L']*(tx+1)
ans+=['U']

print(''.join(ans))

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): ans += "D"

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc051/tasks/abc051_c

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

dx = tx - sx
dy = ty - sy

ans = ''

for a in range(dx):
    ans += 'R'

for b in range(dy + 1):
    ans += 'U'

for c in range(dx + 1):
    ans += 'L'

for d in range(dy + 1):
    ans += 'D'

ans += 'R'

ans += 'D'

for e in range(dx + 1):
    ans += 'R'

for f in range(dy + 1):
    ans += 'U'

for g in range(dx + 1):
    ans += 'L'

for h in range(dy):
    ans += 'D'

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split());x,y=c-a,d-b;u,d,l,r="UDLR";print(u*y+r*x+d*y+l*x+l+u*(y+1)+r*(x+1)+d+r+d*(y+1)+l*(x+1)+u)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
x, y = tx - sx, ty - sy
if x > 0 and y > 0:
  u, d, l, r = "UDLR"
else:
  u, d, l, r = "UDLR"
p = ""
p += u * y
p += r * x
p += d * y
p += l * x
p += l
p += u * (y + 1)
p += r * (x + 1)
p += d
p += r
p += d * (y + 1)
p += l * (x + 1)
p += u
print(p)

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split())
X=c-a
Y=d-b
print('U'*Y+'R'*X+'D'*Y+'L'*(X+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())

answer = ""

answer += "U" * (ty-sy) + "R" * (tx-sx)
answer += "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)

Submission status: Accepted

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

path1 = 'R' * dx + 'U' * dy
path2 = 'L' * dx + 'D' * dy
path3 = 'D' + 'R' * (dx + 1) + 'U' * (dy + 1) + 'L'
path4 = 'U' + 'L' * (dx + 1) + 'D' * (dy + 1) + 'R'

answer = path1 + path2 + path3 + path4
print(answer)

Submission status: Accepted

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

# x軸とy軸の値を揃える関数
def plus_x_arrange(first_x, second_x):
    add_x = ''
    while first_x < second_x:
        add_x += 'R'
        first_x += 1
    return add_x

def plus_y_arrange(first_y, second_y):
    add_y = ''
    while first_y < second_y:
        add_y += 'U'
        first_y += 1
    return add_y

def minus_x_arrange(first_x, second_x):
    add_x = ''
    while first_x < second_x:
        add_x += 'L'
        first_x += 1
    return add_x

def minus_y_arrange(first_y, second_y):
    add_y = ''
    while first_y < second_y:
        add_y += 'D'
        first_y += 1
    return add_y

# 鬼の条件分岐！！
if sx < tx and sy < ty:
    answer += plus_y_arrange(sy, ty)
    answer += plus_x_arrange(sx, tx)
    answer += minus_y_arrange(sy, ty)
    answer += minus_x_arrange(sx, tx)
    answer += 'L'
    answer += plus_y_arrange(sy, ty)
    answer += 'U'
    answer += 'R'
    answer += plus_x_arrange(sx, tx)
    answer += 'D'
    answer += 'R'
    answer += minus_y_arrange(sy, ty)
    answer += 'D'
    answer += 'L'
    answer += minus_x_arrange(sx, tx)
    answer += 'U'

elif sx < tx and sy == ty:
    answer += plus_x_arrange(sx, tx)
    answer += 'D'
    answer += minus_x_arrange(sx, tx)
    answer += 'U'
    answer += 'U'
    answer += plus_x_arrange(sx, tx)
    answer += 'D'
    answer += 'R'
    answer += 'D'
    answer += 'D'
    answer += 'L'
    answer += minus_x_arrange(sx, tx)
    answer += 'L'
    answer += 'U'
    answer += 'U'
    answer += 'R'

elif sx < tx and sy > ty:
    answer += plus_x_arrange(sx, tx)
    answer += minus_y_arrange(sy, ty)
    answer += minus_x_arrange(sx, tx)
    answer += plus_y_arrange(sy, ty)
    answer += 'U'
    answer += plus_x_arrange(sx, tx)
    answer += 'R'
    answer += 'D'
    answer += minus_y_arrange(sy, ty)
    answer += 'L'
    answer += 'D'
    answer += minus_x_arrange(sx, tx)
    answer += 'L'
    answer += 'U'
    answer += plus_y_arrange(sy, ty)
    answer += 'R'

elif sx == tx and sy > ty:
    answer += minus_y_arrange(sx, tx)
    answer += 'R'
    answer += plus_y_arrange(sx, tx)
    answer += 'L'
    answer += 'L'
    answer += minus_y_arrange(sx, tx)
    answer += 'R'
    answer += 'D'
    answer += 'R'
    answer += 'R'
    answer += 'U'
    answer += plus_y_arrange(sx, tx)
    answer += 'U'
    answer += 'L'
    answer += 'L'
    answer += 'D'

elif sx > tx and sy > ty:
    answer += minus_x_arrange(sx, tx)
    answer += minus_y_arrange(sy, ty)
    answer += plus_x_arrange(sx, tx)
    answer += plus_y_arrange(sy, ty)
    answer += 'U'
    answer += minus_x_arrange(sx, tx)
    answer += 'L'
    answer += 'D'
    answer += minus_y_arrange(sy, ty)
    answer += 'R'
    answer += 'D'
    answer += plus_x_arrange(sx, tx)
    answer += 'R'
    answer += 'U'
    answer += plus_y_arrange(sy, ty)
    answer += 'L'

elif sx > tx and sy == ty:
    answer += minus_x_arrange(sx, tx)
    answer += 'U'
    answer += plus_x_arrange(sx, tx)
    answer += 'D'
    answer += 'D'
    answer += minus_x_arrange(sx, tx)
    answer += 'U'
    answer += 'L'
    answer += 'U'
    answer += 'U'
    answer += 'R'
    answer += plus_x_arrange(sx, tx)
    answer += 'R'
    answer += 'D'
    answer += 'D'
    answer += 'L'
    
elif sx > tx and sy < ty:
    answer += minus_x_arrange(sx, tx)
    answer += plus_y_arrange(sy, ty)
    answer += plus_x_arrange(sx, tx)
    answer += minus_y_arrange(sy, ty)
    answer += 'D'
    answer += minus_x_arrange(sx, tx)
    answer += 'L'
    answer += 'U'
    answer += plus_y_arrange(sy, ty)
    answer += 'R'
    answer += 'U'
    answer += plus_x_arrange(sx, tx)
    answer += 'R'
    answer += 'D'
    answer += minus_y_arrange(sy, ty)
    answer += 'L'

else:
    answer += plus_y_arrange(sx, tx)
    answer += 'R'
    answer += minus_y_arrange(sx, tx)
    answer += 'L'
    answer += 'L'
    answer += plus_y_arrange(sx, tx)
    answer += 'R'
    answer += 'U'
    answer += 'R'
    answer += 'R'
    answer += 'D'
    answer += minus_y_arrange(sx, tx)
    answer += 'D'
    answer += 'L'
    answer += 'L'
    answer += 'U'

print(answer)

Submission status: Accepted

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

path1 = 'R' * dx + 'U' * dy
path2 = 'L' * dx + 'D' * dy
path3 = 'D' + 'R' * (dx + 1) + 'U' * (dy + 1) + 'L'
path4 = 'U' + 'L' * (dx + 1) + 'D' * (dy + 1) + 'R'

answer = path1 + path2 + path3 + path4
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = "" ;count = 0 ;pro = 1

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

ans+="R"*(c-a)+"U"*(d-b)
ans+="L"*(c-a)+"D"*(d-b)

ans+="D"+"R"*(c-a+1)+"U"*(d-b+1)+"L"
ans+="U"+"L"*(c-a+1)+"D"*(d-b+1)+"R"


print(ans)

Submission status: Accepted

Solution code:
def solve():
    SX, SY, TX, TY = map(int, input().split())
    # print(SX, SY, "->", TX, TY)

    # 上
    # (SX, SY + 1)
    # (TX, TY + 1)
    # 下
    # (SX, SY - 1)
    # (TX, TY - 1)
    # 左
    # (SX - 1, SY)
    # (TX - 1, TY)
    # 右
    # (SX + 1, SY)
    # (TX + 1, TY)

    right_to_bottom_from_start = "R" + "R" * abs((SX + 1) - TX) + "U" + "U" * abs(SY - (TY - 1))
    left_to_top_from_target = "L" + "L" * abs((TX - 1) - SX) + "D" + "D" * abs(TY - (SY + 1))
    left_to_top_from_start = "L" + "U" * abs(SY - (TY + 1)) + "R" * abs((SX - 1) - TX) + "D"
    right_to_bottom_from_target = "R" + "D" * abs(TY - (SY - 1)) + "L" * abs((TX + 1) - SX) + "U"

    return right_to_bottom_from_start + left_to_top_from_target + left_to_top_from_start + right_to_bottom_from_target


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

Submission status: Accepted

Solution code:
x1,y1,x2,y2 =map(int,input().split())
def_x=x2-x1
def_y=y2-y1

print("U"*def_y+"R"*def_x+"D"*def_y+"L"*def_x+
      "L"+
      "U"*(def_y+1)+"R"*(def_x+1)+
      "D"+"R"+
      "D"*(def_y+1)+"L"*(def_x+1)+"U")

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def c_back_and_forth():
    sx, sy, tx, ty = [int(i) for i in input().split()]
    
    ans = ''
    # (sx,sy)→(tx,ty)
    ans += 'U' * abs(ty - sy) + 'R' * abs(tx - sx)
    # (tx,ty)→(sx,sy)
    ans += 'D' * abs(ty - sy) + 'L' * abs(tx - sx)
    # (sx,sy)→(tx,ty)
    ans += ('L' + 'U' * (abs(ty - sy) + 1)
            + 'R' * (abs(tx - sx) + 1) + 'D')
    # (tx,ty)→(sx,sy)
    ans += ('R' + 'D' * (abs(ty - sy) + 1)
            + 'L' * (abs(tx - sx) + 1) + 'U')
    return ans

print(c_back_and_forth())

Submission status: Accepted

Solution code:
import sys

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

def main():
    dx = tx - sx + 1
    dy = ty - sy + 1
    u, r, d, l = list('URDL')
    
    res = ''
    res += u * (dy - 1)
    res += r * dx
    res += d * dy
    res += l * dx
    res += u + l
    res += u * dy
    res += r * dx
    res += d * dy
    res += l * (dx - 1)
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int,input().split())
up_1 = ty-sy
right_1 = tx-sx
ans = "U"*up_1+"R"*right_1
key = ans
ans += key.replace("U","D").replace("R","L")
up_2 = up_1+1
right_2 = right_1+1
flag = "L"+"U"*up_2+"R"*right_2+"D"
key_2 = flag
ans += flag + key_2.replace("L","x").replace("R","L").replace("x","R").replace("D","y").replace("U","D").replace("y","U")
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

yl = ty - sy
xl = tx - sx

ans = ''
ans += 'U'*yl
ans += 'R'*xl
ans += 'D'*yl
ans += 'L'*(xl+1)
ans += 'U'*(yl+1)
ans += 'R'*(xl+1)
ans += 'DR'
ans += 'D'*(yl+1)
ans += 'L'*(xl+1)
ans += 'U'

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

sx, sy, tx, ty = MAP()

ans = []
for i in range(2):
	dx, dy = tx-sx, ty-sy
	if i==1: ans.append("L")
	ans.extend(["U"]*(dy+i)+["R"]*(dx+i))
	if i==1: ans.extend(["D","R"])
	ans.extend(["D"]*(dy+i)+["L"]*(dx+i))
	if i==1: ans.append("U")
	#print(ans)

print(''.join(ans))