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:
lis = list(map(int, input().split()))
a=lis[0]
b=lis[1]
c=lis[2]
d=lis[3]
x=c-a
y=d-b
 
for i in range(x):
    print('R', end='')
for i in range(y):
    print('U', end='')
for i in range(x):
    print('L', end='')
for i in range(y+1):
    print('D', end='')
for i in range(x+1):
    print('R', end='')
for i in range(y+1):
    print('U', end='')
print('L', end='')
print('U', end='')
for i in range(x+1):
    print('L', end='')
for i in range(y+1):
    print('D', end='')
print('R',end='')

Submission status: Accepted

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

x_diff = tx - x
y_diff = ty - y

first_x_diff = "R" * abs(x_diff) if x_diff > 0 else "L" * abs(x_diff)
first_y_diff = "U" * abs(y_diff) if y_diff > 0 else "D" * abs(y_diff)

first_diff = first_x_diff + first_y_diff
tmp_diff = first_diff.replace("R", "L")
tmp_diff = tmp_diff.replace("U", "D")
first_diff = first_diff + tmp_diff

second_x_diff = "R" * abs(x_diff + 1) if x_diff > 0 else "L" * abs(x_diff + 1)
second_y_diff = "U" * abs(y_diff + 1) if y_diff > 0 else "D" * abs(y_diff + 1)

second_diff = second_x_diff + second_y_diff
tmp_diff = second_diff.replace("R", "L")
tmp_diff = tmp_diff.replace("U", "D")
second_diff = "D" + second_diff + "L" + "U" + tmp_diff + "R"

res = first_diff + second_diff
print(res)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

def main():
    sx,sy,tx,ty = na()
    ret = ""
    for i in range(tx-sx):
        ret += "R"
    for i in range(ty-sy):
        ret += "U"
    for i in range(tx-sx):
        ret += "L"
    for i in range(ty-sy):
        ret += "D"
    ret += "L"
    for i in range(ty-sy+1):
        ret += "U"
    for i in range(tx-sx+1):
        ret += "R"
    ret += "D"
    ret += "R"
    for i in range(ty-sy+1): ret += "D"
    for i in range(tx-sx+1): ret += "L"
    ret += "U"
    print(ret)
    pass


if __name__ == "__main__":
    main()

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

Submission status: Accepted

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

ans = dx[0] * (tx-sx) + dy[0] * (ty - sy)
ans += dx[1] * (tx-sx) + dy[1] * (ty - sy)
ans += (dy[1] + dx[0] * (tx-sx+1) + dy[0] * (ty - sy + 1) + dx[1])
ans += (dy[0] + dx[1] * (tx-sx+1) + dy[1] * (ty - sy + 1) + dx[0])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))

sx, sy, tx, ty = inpl()
res = ""

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

print(res)

Submission status: Accepted

Solution code:
def main():
    """
    1 秒あたり上下左右に距離 1 だけ進むことができます
    sx<tx と sy<ty を満たす点 
    (sx,sy)->(tx,ty)->(sx,sy)->(tx,ty)->(sx,sy)
    (sx,sy) と点(tx,ty) を除いて、途中で同じ座標を複数回通らないように移動しなければなりません。

    −1000≦sx<tx≦1000
    −1000≦sy<ty≦1000

    最短距離: マンハッタン距離
    to (tx,ty)N=1: 最短距離OK
    to (sx,sy)N=2: 最短距離OK
    to (tx,ty)N=3: 最短距離NG
    to (sx,sy)N=4: 最短距離NG
    """
    sx, sy, tx, ty = map(int, input().split())

    diff_x = tx - sx
    diff_y = ty - sy
    # Up -> Right
    # Down -> Left
    # Left -> Up -> Right -> Down
    # Right -> Down -> Left -> Up
    route = [
        "U" * diff_y + "R" * diff_x,
        "D" * diff_y + "L" * diff_x,
        "L" + "U" * (diff_y + 1) + "R" * (diff_x + 1) + "D",
        "R" + "D" * (diff_y + 1) + "L" * (diff_x + 1) + "U",
    ]
    for r in route:
        print(r, end="")
    print("")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x,y,sx,sy=map(int,raw_input().split())
#print x,y,sx,sy

a=[]
#1st
#Go
for i in range(sy-y):
	a.append("U")
for i in range(sx-x):
	a.append("R")
#Back
for i in range(sy-y):
	a.append("D")
for i in range(sx-x):
	a.append("L")

#2nd
#Go
a.append("L")
for i in range((sy+1)-y):
	a.append("U")
for i in range(sx-(x-1)):
	a.append("R")
a.append("D")

#Back
a.append("R")
for i in range(sy-(y-1)):
	a.append("D")
for i in range((sx+1)-x):
	a.append("L")
a.append("U")

#print a
print "".join(a)

Submission status: Accepted

Solution code:
def solve():
    s_x, s_y, t_x, t_y = list(map(int, input().split(" ")))

    print("D", end="")

    for _ in range(t_x - s_x + 1):
        print("R", end="")
    for _ in range(t_y - s_y + 1):
        print("U", end="")

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

    for _ in range(t_x - s_x + 1):
        print("L", end="")
    for _ in range(t_y - s_y + 1):
        print("D", end="")

    print("R", end="")

    for _ in range(t_x - s_x):
        print("R", end="")
    for _ in range(t_y - s_y):
        print("U", end="")
    for _ in range(t_x - s_x):
        print("L", end="")
    for _ in range(t_y - s_y):
        print("D", end="")


solve()

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy

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

Submission status: Accepted

Solution code:
s = raw_input().split()
a= int(s[0]) 
b= int(s[1])
c= int(s[2])
d= int(s[3])

w = c-a 
h = d-b 
u ="U"
d = "D"
r = "R"
l = "L"

str = "U"*h + "R"*w + "D"*h + "L"*w + "L" + u*(h+1) + r*(w+1) + d + r + d*(h+1) + l*(w+1) + u  
print str

Submission status: Accepted

Solution code:
x, y, tx, ty = [int(i) for i in input().split()]
ans = []
for i in range(ty - y):
    ans.append('U')
for i in range(tx - x):
    ans.append('R')
for i in range(ty - y):
    ans.append('D')
for i in range(tx - x + 1):
    ans.append('L')
for i in range(ty - y + 1):
    ans.append('U')
for i in range(tx - x + 1):
    ans.append('R')
ans.append('DR')
for i in range(ty - y + 1):
    ans.append('D')
for i in range(tx - x + 1):
    ans.append('L')
ans.append('U')
ans = ''.join(ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

# 往路1:x
ans += (tx - sx) * "R"
# 往路1:y
ans += (ty - sy) * "U"
# 復路1:x
ans += (tx - sx) * "L"
# 復路1:y
ans += (ty -sy) * "D"

# 往路2:x
ans += "D"
ans += ((tx - sx)+1) * "R"

# 往路2:y
ans += ((ty - sy)+1) * "U"
ans += "L"

#　復路2:x
ans += "U"
ans += ((tx - sx)+1) * "L"

#復路2:y
ans += ((ty -sy)+1) * "D"
ans += "R"

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict


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

    print("R" * x + "U" * y, end="")
    print("L" * x + "D" * y, end="")
    print("D" + "R" * (x + 1) + "U" * (y + 1) + "L", end="")
    print("U" + "L" * (x + 1) + "D" * (y + 1) + "R")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
sx, sy, tx, ty = list(map(int, input().split()))
y = ty-sy
x = tx-sx
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, raw_input().split())
dx = tx-sx
dy = ty-sy
PATH = 'U'*dy + 'R'*dx + '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, raw_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:
sx,sy,tx,ty=map(int,input().split())
east=tx-sx
north=ty-sy
ans="R"*east+"U"*north
ans+="L"*east+"D"*north
ans+="D"+"R"*(east+1)+"U"*(north+1)+"L"
ans+="U"+"L"*(east+1)+"D"*(north+1)+"R"

print(ans)

Submission status: Accepted

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

sx,sy,tx,ty = map(int, raw_input().split())
width = int(math.fabs(ty-sy))
height = int(math.fabs(tx-sx))

path = ''
for i in range(width):
    path += 'U'
for i in range(height):
    path += 'R'
for i in range(width):
    path += 'D'
for i in range(height):
    path += 'L'

path += 'L'
for i in range(width+1):
    path += 'U'
for i in range(height+1):
    path += 'R'
path += 'D'
path += 'R'
for i in range(width+1):
    path += 'D'
for i in range(height+1):
    path += 'L'
path += 'U'
    
print(path)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int, raw_input().split())
x = tx - sx
y = ty - sy
route = ''
for _ in range(y):
    route += 'U'
for _ in range(x):
    route += 'R'
for _ in range(y):
    route += 'D'
for _ in range(x):
    route += 'L'
route += 'L'
for _ in range(y+1):
    route += 'U'
for _ in range(x+1):
    route += 'R'
route += 'D'
route += 'R'
for _ in range(y+1):
    route += 'D'
for _ in range(x+1):
    route += 'L'
route += 'U'
print route

Submission status: Accepted

Solution code:
def main(sx, sy, tx, ty):
    answer = ''
    d_x = tx - sx
    d_y = ty - sy

    one_right = 'R' * d_x
    one_up    = 'U' * d_y
    answer += one_up + one_right

    one_down  = 'D' * d_y
    one_left  = 'L' * (d_x + 1)
    answer += one_down + one_left

    two_up    = 'U' * (d_y + 1)
    two_right = 'R' * (d_x + 1)
    answer += two_up + two_right + 'DR'

    two_down  = 'D' * (d_y + 1)
    two_left  = 'L' * (d_x + 1)
    answer += two_down + two_left + 'U'

    return answer

# print(main(
#     0, 0, 1, 2
# ))

if __name__ == '__main__':
    sx, sy, tx, ty = [int(e) for e in input().split()]
    print(main(sx, sy, tx, ty))

Submission status: Accepted

Solution code:
def route_x(sx, tx):
    dx = tx - sx
    dx2 = dx if dx >= 0 else -dx
    buf = "R"*dx2 if dx >= 0 else "L"*dx2
    return buf

def route_y(sy, ty):
    dy = ty - sy
    dy2 = dy if dy >= 0 else -dy
    buf = "U"*dy2 if dy >= 0 else "D"*dy2
    return buf

def route(sx, sy, tx, ty):
    return route_x(sx, tx) + route_y(sy, ty)

def route2(sx, sy, tx, ty):
    dx = tx - sx
    dy = ty - sy
    if dx >= 0 and dy >= 0:
        buf = "L" + route_y(sy, ty+1) + route_x(sx-1, tx) + "D"
    if dx >= 0 and dy < 0:
        buf = "U" + route_x(sx, tx+1) + route_y(sy+1, ty) + "L"
    if dx < 0 and dy >= 0:
        buf = "D" + route_x(sx, tx-1) + route_y(sy-1, ty) + "R"
    if dx < 0 and dy < 0:
        buf = "R" + route_y(sy, ty-1) + route_x(sx+1, tx) + "U"
    return buf

if __name__ == "__main__":
    sx, sy, tx, ty = [int(i) for i in input().split()]
    r1 = route(sx, sy, tx, ty) + route(tx, ty, sx, sy)
    r2 = route2(sx, sy, tx, ty) + route2(tx, ty, sx, sy)
    print(r1 + r2)

Submission status: Accepted

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

sx, sy, tx, ty = map(int, raw_input().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:
sx,sy,tx,ty = map(int,input().split(' '))
w,h = abs(sx-tx),abs(sy-ty)

res = 'U'*h+'R'*w+'D'*h+'L'*w
res += 'L'+'U'*(h+1)+'R'*(w+1)+'DR'+'D'*(h+1)+'L'*(w+1)+'U'
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
INF=10**10

def main():
    
    sx,sy,tx,ty=list(map(int,input().split()))
    dx,dy=tx-sx,ty-sy
   
    s=""
    s+="R"*dx+"U"*dy
    s+="L"*dx+"D"*dy
    s+="D"+"R"*(dx+1)+"U"*(dy+1)+"L"
    s+="U"+"L"*(dx+1)+"D"*(dy+1)+"R"
    print(s)
    
    
if __name__=="__main__":
    main()

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
      + 'L' + 'U' * (dy + 1) + 'R' * (dx + 1)
      + 'DR' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U')

Submission status: Accepted

Solution code:
pos = list(map(int, input().split()))
sx = pos[0]
sy = pos[1]
tx = pos[2]
ty = pos[3]

dx = tx - sx
dy = ty - sy

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

print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = [int(x) for x in input().split()]

# 1周目
dx = tx - sx
dy = ty - sy
route1 = "U" * dy + "R" * dx + "D" * dy + "L" * dx

# 2周目
route2 = "L" + "U" * (dy + 1) + "R" * (dx + 1) + "D" + "R" + "D" * (dy + 1) + "L" * (dx + 1) + "U"

print(route1 + route2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nums = list(map(int, input().split()))
x = nums[2] -nums[0]
y = nums[3] - nums[1]
a = 'R' * x + 'U'* y
b = 'L' * x + 'D'* y
c = 'D' + 'R' * (x+1) + 'U'* (y+1) + 'L'
d = 'U' + 'L' * (x+1) + 'D'* (y+1) + 'R'
print(a+b+c+d)

Submission status: Accepted

Solution code:
point=input().split(" ")
sx=int(point[0])
sy=int(point[1])
tx=int(point[2])
ty=int(point[3])



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

print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

line = input().split()
sx, sy, tx, ty = int(line[0]), int(line[1]), int(line[2]), int(line[3])

result = ""




if ty > sy:
    if tx > sx:
        result += "U" * (ty - sy)
        result += "R" * (tx - sx)
        result += "D" * (ty - sy)
        result += "L" * (tx - sx)
        result += "L" + "U"*(ty-sy + 1)
        result += "R"*(tx - sx + 1) + "D"
        result += "R" + "D"*(ty-sy + 1)
        result += "L"*(tx-sx + 1) + "U"
    else:
        result += "U" * (ty - sy)
        result += "L" * (tx - sx)
        result += "D" * (ty - sy)
        result += "R" * (tx - sx)
        result += "R" + "U" * (ty - sy + 1)
        result += "L" * (tx - sx + 1) + "D"
        result += "L" + "D" * (ty - sy + 1)
        result += "R" * (tx - sx + 1) + "U"

else:
    if tx > sx:
        result += "D" * (ty - sy)
        result += "R" * (tx - sx)
        result += "U" * (ty - sy)
        result += "L" * (tx - sx)
        result += "L" + "D" * (ty - sy + 1)
        result += "R" * (tx - sx + 1) + "U"
        result += "R" + "U" * (ty - sy + 1)
        result += "L" * (tx - sx + 1) + "D"
    else:
        result += "D" * (ty - sy)
        result += "L" * (tx - sx)
        result += "U" * (ty - sy)
        result += "R" * (tx - sx)
        result += "R" + "D" * (ty - sy + 1)
        result += "L" * (tx - sx + 1) + "U"
        result += "L" + "U" * (ty - sy + 1)
        result += "R" * (tx - sx + 1) + "D"

print(result)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
sx, sy, tx, ty = map(int,input().split())
movelist = ['U','D','L','R']
moved = []
countX = tx - sx
countY = ty - sy
#first movement
for y in range (0, countY):
    moved.append(movelist[0])

for x in range (0, countX):
    moved.append(movelist[3])

#second movement
for y in range (0, countY):
    moved.append(movelist[1])

for x in range (0, countX):
    moved.append(movelist[2])

#third movement

moved.append(movelist[2])

for y in range (0, countY+1):
    moved.append(movelist[0])

for x in range (0, countX+1):
    moved.append(movelist[3])

moved.append(movelist[1])

#forth movement
moved.append(movelist[3])

for y in range (0,countY+1):
    moved.append(movelist[1])

for x in range (0, countX+1):
    moved.append(movelist[2])

moved.append(movelist[0])

print("".join(moved))

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int,input().split())
x = tx - sx
y = ty - sy
s = ''
#一周目
s += 'R'*x
s += 'U'*y
s += 'L'*x
s += 'D'*y
#2周目
s += 'D'
s += 'R'*(x+1)
s += 'U'*(y+1)
s += 'L'
s += 'U'
s += 'L'*(x+1)
s += 'D'*(y+1)
s += 'R'
print(s)

Submission status: Accepted

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

ans = ''

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

# 2周目
for _ in range(tx-sx):
    ans += 'R'
for _ in range(ty-sy+1):
    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:
sx,sy,tx,ty = [int(i) for i in raw_input().split(' ')]
x = tx-sx
y = ty-sy
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:
import numpy as np

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

x = tx-sx
y = ty-sy

f=""
b=""

for i in range(x):
    f=f+"R"
    b=b+"L"
for i in range(y):
    f=f+"U"
    b=b+"D"


print f+b+"DR"+f+"UL"+"UL"+b+"DR"

Submission status: Accepted

Solution code:
sx,sy,dx,dy=map(int,raw_input().split())
x=dx-sx
y=dy-sy
s=""
for i in xrange(x):
	s+="R"
for i in xrange(y):
	s+="U"
for i in xrange(x):
	s+="L"
for i in xrange(y):
	s+="D"
s+="D"
for i in xrange(x+1):
	s+="R"
for i in xrange(y+1):
	s+="U"
s+="L"
s+="U"
for i in xrange(x+1):
	s+="L"
for i in xrange(y+1):
	s+="D"
s+="R"
print s

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ARC051C

sx,sy,tx,ty=map(int,raw_input().split())
x=tx-sx
y=ty-sy
print 'R'*x+'U'*y+'L'*x+'D'*y+'D'+'R'*(x+1)+'U'*(y+1)+'L'+'U'+'L'*(x+1)+'D'*(y+1)+'R'

Submission status: Accepted

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

ans=""

ans+="R"*dx
ans+="U"*dy

ans+="L"*dx
ans+="D"*dy

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

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

print(ans)

Submission status: Accepted

Solution code:




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

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

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+'L'+'U'*(dy+1)+'R'*(dx+1)+'D'+'R'+'D'*(dy+1)+'L'*(dx+1)+'U'
print(ans)

Submission status: Accepted

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

#行き1の経路:y軸から移動,x軸最後に移動
for i in range(y_diff):
    route += 'U'
for i in range(x_diff):
    route += 'R'

#帰り1の経路:y軸降りる,x軸左に
for i in range(y_diff):
    route += 'D'
for i in range(x_diff):
    route += 'L'

#行き2の経路:左に1ずれ,上にy_diff+1移動した後x_diff+1移動し1降りる
route += 'L'
for i in range(y_diff+1):
    route += 'U'
for i in range(x_diff+1):
    route += 'R'
route += 'D'

#帰り2の経路:右1ずれ,下y_diff+1移動,x_diff+1左移動し1上に
route += 'R'
for i in range(y_diff+1):
    route += 'D'
for i in range(x_diff+1):
    route += 'L'
route += 'U'
print(route)

Submission status: Accepted

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

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

w = tx - sx
h = ty - sy

str1 = "R" * w + "U" * h + "L" * w + "D" * h
str2 = "D" + "R" * (w + 1) + "U" * (h + 1) + "L" + "U" + "L" * (w + 1) +"D" * (h + 1) + "R"
print(str1 + str2)

Submission status: Accepted

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

ans1 = ""
ans2 = ""

for i in range(dx):
    ans1 += "R"
    ans2 += "L"

for i in range(dy):
    ans1 += "U"
    ans2 += "D"

ans = ans1 + ans2
ans1 = "D"
ans2 = "U"

for i in range(dx + 1):
    ans1 += "R"
    ans2 += "L"

for i in range(dy + 1):
    ans1 += "U"
    ans2 += "D"

ans1 += "L"
ans2 += "R"

print(ans + ans1 + ans2)

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int,input().split())
dy , dx = ty-sy,tx-sx
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:
def commands(sx, sy, tx, ty):
    ans = ""
    ans += "R" * max(0, tx - sx)
    ans += "L" * max(0, sx - tx)
    ans += "U" * max(0, ty - sy)
    ans += "D" * max(0, sy - ty)
    return ans


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

res = ""
res += commands(sx, sy, tx, ty)
res += commands(tx, ty, sx, sy)
res += "D" + commands(sx, sy - 1, tx + 1, ty) + "L"
res += "U" + commands(tx, ty + 1, sx - 1, sy) + "R"

print res

Submission status: Accepted

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

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

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


def main():
    sx,sy,tx,ty = LI()
    r = ''
    x = ty-sy
    y = tx-sx
    r += 'U'*x
    r += 'R'*y
    r += 'U'
    r += 'L'*(y+1)
    r += 'D'*(x+1)
    r += 'R'

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

    return r


print(main())

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, raw_input().split())
ans = ""
nx = tx - sx
ny = ty - sy
ans += "U" * ny
ans += "R" * nx
ans += "D" * ny
ans += "L" * nx
ans += "LU"
ans += "U" * ny
ans += "R" * nx
ans += "RD"
ans += "RD"
ans += "D" * ny
ans += "L" * nx
ans += "LU"
print ans

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 解説を読んで実装

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

dx, dy = tx - sx, ty - sy

sx = 'R'
sy = 'U'

trans = str.maketrans('UDRL', 'DULR')
def rev(s):
    return s.translate(trans)

first = sx * dx + sy * dy
print(first, end='')
print(rev(first), end='')

second = rev(sy) + sx + first + sy + rev(sx)
print(second, end='')
print(rev(second), end='')

Submission status: Accepted

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

vec = []
x, y = sx, sy
for i in range(ty - sy - 1):
    vec.append("U")
    y += 1

for i in range(tx - sx - 1):
    vec.append("R")
    x += 1

for i in range(ty - y):
    vec.append("U")
    y += 1

for i in range(tx - x):
    vec.append("R")
    x += 1

vec.append("R")
x += 1

for i in range(ty - sy + 1):
    vec.append("D")
    y -= 1

for i in range(x - sx):
    vec.append("L")
    x -= 1

vec.append("U")
y += 1
vec.append("L")
x -= 1

for i in range(ty + 1 - y):
    vec.append("U")
    y += 1

for i in range(tx - x):
    vec.append("R")
    x += 1

vec.append("D")
y -= 1

vec.append("D")
y -= 1

for i in range(ty - sy - 1):
    vec.append("D")
    y -= 1

for i in range(tx - sx - 1):
    vec.append("L")
    x -= 1

for i in range(y - sy):
    vec.append("D")
    y -= 1

for i in range(x - sx):
    vec.append("L")
    x -= 1

# print(vec)
# print(x, y)
for v in vec:
    print(v, end="")

Submission status: Accepted

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

dx, dy = tx - sx, ty - sy

sx = 'R' if dx >= 0 else 'L'
sy = 'U' if dy >= 0 else 'D'

first = sx * abs(dx) + sy * abs(dy)

trans = str.maketrans('UDRL', 'DULR')
def rev(s):
    return s.translate(trans)


print(first, end='')

if dx != 0 and dy != 0:
    print(rev(first), end='')
    d = 'R' if dx > 0 else 'L'
    d2 = 'D' if dy > 0 else 'U'
    second = d2 + d + first + rev(d2) + rev(d)
    print(second, end='')
    print(rev(second), end='')
    
else:
    d = 'R' if dx is 0 else 'U'
    second = d + rev(first) + rev(d)
    print(second, end='')
    
    print(rev(second), end='')
    d2 = first[0]
    print(d2, d * 2, rev(d2), rev(first), rev(d2), rev(d) * 2, rev(d2), sep='', end='')

Submission status: Accepted

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

diff_x = tx - sx
diff_y = ty - sy

print('R'*diff_x + 'U'*diff_y + 'L'*diff_x + 'D'*diff_y
      + 'D' + 'R'*(diff_x+1) + 'U'*(diff_y+1) + 'L'
      + 'U' + 'L'*(diff_x+1) + 'D'*(diff_y+1) + 'R')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sx,sy,tx,ty = map(int, raw_input().split())
for x in range(0,tx-sx):
 sys.stdout.write('R')
for x in range(0,ty-sy):
 sys.stdout.write('U')
for x in range(0,tx-sx):
 sys.stdout.write('L')
for x in range(0,ty-sy):
 sys.stdout.write('D')
sys.stdout.write('D')
for x in range(0,tx-sx+1):
 sys.stdout.write('R')
for x in range(0,ty-sy+1):
 sys.stdout.write('U')
sys.stdout.write('L')
sys.stdout.write('U')
for x in range(0,tx-sx+1):
 sys.stdout.write('L')
for x in range(0,ty-sy+1):
 sys.stdout.write('D')
sys.stdout.write('R')