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: Wrong Answer

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

from collections import defaultdict, deque
Dirc = ('U', 'D', 'R', 'L')
Dirc2 = ('D', 'U', 'L', 'R')
dircn = ((1, 0), (-1, 0), (0, 1), (0, -1))
blocked = defaultdict(int)
sx, sy, tx, ty = mapint()

ans = []
for i in range(4):
    queue = deque([(sx, sy, [])])
    checked = defaultdict(int)
    dirc = Dirc if i%2==0 else Dirc2
    while queue:
        x, y, lis = queue.popleft()
        lis = lis[:]
        flg = 0
        for d, (dy, dx) in zip(dirc, dircn):
            nx, ny = x+dx, y+dy
            if checked[(nx, ny)] or blocked[(nx, ny)]:
                continue
            if nx==sx and ny==sy:
                continue
            if nx==tx and ny==ty:
                flg = 1
                lis.append(d)
                break
            lis.append(d)
            queue.append((nx, ny, lis))
            lis.pop()
            checked[(nx, ny)] = 1
        if flg:
            x, y = sx, sy
            for s in lis[:-1]:
                dy, dx = dircn[dirc.index(s)]
                x += dx
                y += dy
                blocked[(x, y)] = 1
            if i%2==0:
                lis = list(reversed(lis))
            ans.extend(lis)
            break
print(''.join(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

path="R"*x+"U"*(y+1)+"L"*x+"D"*(y+2)+"R"*(x+1)+"U"*(y+1)+"L"*(x+2)+"D"*y+"R";

print(path)

Submission status: Wrong Answer

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


def calculate(sx, sy, tx, ty):

    width = abs(sx-tx)
    height = abs(sy-ty)

    if tx - sx > 0:
        if ty - sy > 0:
            Up = 'U'
            Down = 'D'
            Left = 'L'
            Right = 'R'
        else:
            Up = 'D'
            Down = 'U'
            Left = 'L'
            Right = 'R'
    else:
        if ty - sy > 0:
            Up = 'U'
            Down = 'D'
            Left = 'R'
            Right = 'L'
        else:
            Up = 'D'
            Down = 'U'
            Left = 'R'
            Right = 'L'

    print(Up*height + Right*width + Down*height + Left*width + Left + Up*(height+1) + Right*(width+2) + Down * (height + 2) + Left * (width + 1) + Up)


calculate(sx,sy,tx,ty)

Submission status: Wrong Answer

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

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

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

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


# ===CODE===


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

    ans = []

    ans.extend(["U"] * (ty - sy))
    ans.extend((["R"] * (tx - sx)))
    ans.extend(["D"] * ((ty - sy)))
    ans.extend((["L"] * (tx - sx)))

    ans.extend(["LU"] * (ty - sy))

    ans.extend(["U"] * (ty - sy))
    ans.extend((["R"] * (tx - sx)))
    
    ans.extend(["RD"] * (ty - sy))
    
    ans.extend(["D"] * ((ty - sy)))
    ans.extend((["L"] * (tx - sx)))

    ans.extend(["LU"] * (ty - sy))

    print(*ans, sep="")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

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


# ===CODE===


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

    ans = []

    ans.extend(["U"] * (ty - sy))
    ans.extend((["R"] * (tx - sx)))
    ans.extend(["D"] * ((ty - sy)))
    ans.extend((["L"] * (tx - sx)))

    print(*ans, sep="")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
sx, sy, tx, ty = map(int, input().split())
x, y = tx - sx, ty - sy
print("R"*x + "U"*-~y + "L"*-~x + "D"*-~y + "R" + "U"*x + "R"*-~x + "D"*-~y + "L"*-~x + "U")

Submission status: Wrong Answer

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

if tx - sx > 0:
    lr = ["R", "L"]
else:
    lr = ["L", "R"]
if ty - tx > 0:
    ud = ["U", "D"]
else:
    ud = ["D", "U"]

x = abs(tx - sx)
y = abs(ty - sy)

print(lr[0] * x + ud[0] * y + lr[1] * x + ud[1] * y + lr[1] + ud[0] * (y + 1) + lr[0] * (x + 1) + ud[1] + lr[0] + ud[1] * (y + 1) + lr[1] * (x + 1) + ud[0])

Submission status: Wrong Answer

Solution code:
X = list(map(int, input().split()))
sx = X[0]
sy = X[1]
tx = X[2]
ty = X[3]
x = tx - sx
y = ty - sy
print(x, y)
l1 = "U" * y + "R" * x
l2 = "D" * y + "L" * x
l3 = "L" + "U" * (y + 1) + "R" * (x + 1) + "D"
l4 = "R" + "D" * (y + 1) + "L" * (x + 1) + "U"
print(l1 + l2 + l3 + l4)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x_s, y_s, x_t, y_t = map(int, input().split())
dist_x, dist_y = x_t - x_s, y_t - y_s

ans = ""
ans += ("R" * dist_x)
ans += ("U" * dist_y)
ans += ("L" * dist_x)
ans += ("D" * dist_y)
ans += "U"
ans += ("R" * (dist_x + 1))
ans += ("U" * (dist_y + 1))
ans += "LL"
ans += ("L" * (dist_x + 1))
ans += ("D" * (dist_y + 1))
ans += "R"

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

current = [sx, sy]
# (0,0), (1,2)

# 最短距離で横・縦に進む
while current[0] != tx:
    current[0] += 1
    ans += "R"
while current[1] != ty:
    current[1] += 1
    ans += "U"

# 最短距離で横・縦に戻る
while current[0] != sx:
    current[0] -= 1
    ans += "L"
while current[1] != sy:
    current[1] -= 1
    ans += "D"

# 一歩だけ縦に離れる
current[1] -= 1
ans += "D"

# txを一つ超える分まで横に進む
while current[0] != tx+1:
    current[0] += 1
    ans += "R"
# tyと同じ高さまで縦に進む
while current[1] != ty:
    current[1] += 1
    ans += "U"

#一歩だけ横に進んでtx,tyに到着する
current[0] -= 1
ans += "L"

#一歩だけ縦に離れる
current[1] += 1
ans += "U"

# sxを一つ超える分まで横に進む
while current[0] != tx+1:
    current[0] += 1
    ans += "L"

# syと同じ高さまで縦に進む
while current[1] != ty:
    current[1] -= 1
    ans += "D"

#一歩だけ横に進んでsx,syに到着する
current[0] += 1
ans += "R"

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
sx, sy, tx, ty = map(int, input().split())
ver = ty - sy
hor = tx - sx
go1 = 'U'*ver+"R"*hor
back1 = "D"*ver+"L"*hor
go2 = "D"+"R"*(hor+1)+'U'*(ver+1)
back2 = "U"+"L"*(hor+1)+"D"*(ver+1)+"R"
print(go1+back1+go2+back2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

dx = tx-sx
dy = ty-sy

# first
path.append('U'*dy)
path.append('R'*dx)

# second
path.append('D'*dy)
path.append('L'*dx)

# third
path.append('L')
path.append('U'*(dy+1))
path.append('R'*(dx+1))

# forth
path.append('R')
path.append('D'*(dy+1))
path.append('L'*(dx+1))
path.append('U')

print(''.join(path))

Submission status: Wrong Answer

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

xd = tx - sx
yd = ty - sy

route1 = []
route1.append('R'*xd)
route1.append('U'*yd)

route2 = []
route2.append('L'*xd)
route2.append('D'*yd)

route3 = ['D']
route3.append('R' * (xd + 1))
route3.append('U' * (yd + 1))
route3.append('L')

route4 = ['U']
route4.append('L'*(xd+1))
route4.append('D'*(yd+1))
route4.append('R')

ans = ''.join(route1) + ''.join(route2) + ''.join(route2) + ''.join(route4)
print(ans)

Submission status: Wrong Answer

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

ans=[]

#sの上->tの左 ↑→
sx1=sx
sy1=sy+1
tx1=tx-1
ty1=ty
ans.append('U')
ans.extend(['U']*(ty1-sy1))
ans.extend(['R']*(tx1-sx1))
ans.append('R')

#tの下->sの右  ↓←
sx2=sx+1
sy2=sy
tx2=tx
ty2=ty-1
ans.append('D')
ans.extend(['D']*(ty2-sy2))
ans.extend(['L']*(tx2-sx2))
ans.append('L')

#sの下->tの右 ↓→↑←
sx3=sx
sy3=sy-1
tx3=tx+1
ty3=ty
ans.append('D')
ans.extend(['R']*(tx3-sx3))
ans.extend(['U']*(ty3-sy3))
ans.append('L')

#tの上->sの左 ↑←↓→
sx4=sx+1
sy4=sy
tx4=tx
ty4=ty+1
ans.append('U')
ans.extend(['L']*(tx4-sx4))
ans.extend(['D']*(ty4-sy4))
ans.append('R')

print(''.join(ans))

Submission status: Wrong Answer

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

ans=[]

#s->t ↑→
sx1=sx
sy1=sy+1
tx1=tx-1
ty1=ty
ans.append('U')
ans.extend(['U']*(ty1-sy1))
ans.extend(['R']*(tx1-sx1))
ans.append('R')

#t->s  ↓←
sx2=sx+1
sy2=sy
tx2=tx
ty2=ty-1
ans.append('D')
ans.extend(['D']*(ty2-sy2))
ans.extend(['L']*(tx2-sx2))
ans.append('L')

#s->t ↓→↑←
sx3=sx
sy3=sy-1
tx3=tx+1
ty3=ty
ans.append('D')
ans.extend(['R']*(tx3-sx3))
ans.extend(['U']*(ty3-sy3))
ans.append('L')

#t->s ↑←↓→
sx4=sx+1
sy4=sy
tx4=tx
ty4=ty-1
ans.append('U')
ans.extend(['L']*(tx4-sx4))
ans.extend(['D']*(ty4-sy4))
ans.append('R')

print(''.join(ans))

Submission status: Wrong Answer

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

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

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

print("".join(ans))

Submission status: Wrong Answer

Solution code:
sx,sy,tx,ty = map(int,input().split())
# 距離 s < tより
dx = tx - sx
dy = ty - sy

res = ""
# 1回目
# いきし
for i in range(dx):
    res += "R"
for i in range(dy):
    res += "U"
# かえりし
for i in range(dx):
    res += "L"
for i in range(dy):
    res += "D"

# 2回目
# いきし 1回上に上がる dx + 1いく
res += "U"
for i in range(dx+1):
    res += "R"
for i in range(dy+1):
    res += "U"
res += "L"
# かえりし 1回下がっとく
res += "D"
for i in range(dx+1):
    res += "L"
for i in range(dy+1):
    res += "D"
res += "R"
print(res)

Submission status: Wrong Answer

Solution code:
sx,sy,tx,ty = map(int,input().split())
# 距離 s < tより
dx = tx - sx
dy = ty - sy

res = ""
# 1回目
# いきし
for i in range(dx):
    res += "R"
for i in range(dy):
    res += "D"
# かえりし
for i in range(dx):
    res += "L"
for i in range(dy):
    res += "U"

# 2回目
# いきし 1回上に上がる dx + 1いく
res += "U"
for i in range(dx+1):
    res += "R"
for i in range(dy+1):
    res += "D"
res += "L"
# かえりし 1回下がっとく
res += "D"
for i in range(dx+1):
    res += "L"
for i in range(dy+1):
    res += "U"
res += "R"
print(res)

Submission status: Wrong Answer

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

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

if sx > tx: ans += "L"
else: ans += "R" 

print(ans)

Submission status: Wrong Answer

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

ans = []
ans += ['L' if sx > tx else 'R'] * abs(sx - tx)
ans += ['U' if sy < ty else 'D'] * abs(sy - ty)

if ans[-1] == 'R' or ans[-1] == 'L':
    ans += 'U'
    ty += 1
ans += ['L' if sx < tx else 'R'] * abs(sx - tx)
ans += ['U' if sy > ty else 'D'] * abs(sy - ty)

print(''.join(ans))

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

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

ans = []
ans += ['L' if sx > tx else 'R'] * abs(sx - tx)
ans += ['U' if sy < ty else 'D'] * abs(sy - ty)
ans += ['U' if sy < ty else 'D']

ty += 1 if ans[-1] == 'U' else -1
ans += ['L' if sx < tx else 'R'] * abs(sx - tx)
ans += ['U' if sy > ty else 'D'] * abs(sy - ty)

print(''.join(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    a, b, c, d = map(int, input().split())
    dx, dy = (c - a), (d - b)
    p1 = "L" + "U" * dy + "R" * dx + "D" + "L" * dx + "D" * dy
    p2 = "D" + "R" * dx + "U" * dy + "L" + "D" * dy + "L" * dx
    print(p1 + p2)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    a, b, c, d = map(int, input().split())
    dx, dy = (c - a), (d - b)
    ans = "U" * dy + "R" * dx + "D" * dy + "L" * dx
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


def solve(sx, sy, tx, ty):
    dx = tx - sx
    dy = ty - sy
    st = 'U' * dy + 'R' * dx
    ts = 'D' * dy + 'L' * dy
    rt1 = st + ts
    rt2 = 'L' + 'U' + st + 'R' + 'D' + 'R' + 'D' + ts + 'L' + 'U'
    ans = rt1 + rt2
    return ans


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
data = list(map(int, input().split()))

x = data[2] - data[0]
y = data[3] - data[1]

go = x * "U" + y * "R"
come = x * "D" + y * "L"

path = go + come

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

ans = path + temp
print(ans)

Submission status: Wrong Answer

Solution code:
data = list(map(int, input().split()))

x = data[2] - data[0]
y = data[3] - data[1]

go = x * "U" + y * "R"
come = x * "D" + y * "L"

path = (go + come) * 2
print(path)

Submission status: Wrong Answer

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

dx = tx - sx
dy = ty - sy

iki_yoko = 'R' if dx >= 0 else 'L'
kaeri_yoko = 'L' if dx >= 0 else 'R'
iki_tate = 'U' if dx >= 0 else 'D'
kaeri_tate = 'D' if dx >= 0 else 'U'

print(iki_yoko*abs(dx) + iki_tate*abs(dy) + kaeri_yoko*abs(dx) + kaeri_tate*abs(dy) + kaeri_tate + iki_yoko*abs(dx) + iki_tate*abs(dy) + kaeri_yoko + iki_tate + kaeri_yoko*abs(dx) + kaeri_tate*abs(dy) + iki_yoko)

Submission status: Wrong Answer

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

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

up_shift = ty - sx
for i in range(up_shift):
    print('U', end='')

for i in range(right_shift):
    print('L', end='')

for i in range(up_shift + 1):
    print('D', end='')

for i in range(right_shift + 1):
    print('R', end='')

for i in range(up_shift + 1):
    print('U', end='')

for i in range(right_shift + 1):
    print('L', end='')

for i in range(up_shift + 1):
    print('D', end='')
    
print('R')

Submission status: Wrong Answer

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

X = tx-sx
Y = ty-sy

print('R'*X+'U'*Y+'L'*X+'D'*Y+'D'+'R'*(X+1) +
      'U'*(Y+1)+'L'+'L'*(X+1)+'D'*(Y+1)+'R')

Submission status: Wrong Answer

Solution code:
import sys

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

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

path = path_s + path_e + "D" + path_s + "L" + "U" + path_e + "R"
print(path)

Submission status: Wrong Answer

Solution code:
def main():
    sx, sy, tx, ty = map(int, input().split())
    u = ''.join('U' * (ty - sy))
    r = ''.join('R' * (tx - sx))
    d = ''.join('D' * (ty - sy))
    l = ''.join('L' * (tx - sx))
    ans = ''.join([u, r, d, l])
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
print([x, y])


def add(A, item, times):
    for _ in range(times):
        A.append(item)


answer = []
add(answer, 'U', x)
add(answer, 'R', y)
add(answer, 'R', 1)
add(answer, 'D', y+1)
add(answer, 'L', x+1)
add(answer, 'U', 1)
add(answer, 'R', y)
add(answer, 'U', x)
add(answer, 'U', 1)
add(answer, 'L', x+1)
add(answer, 'D', y+1)
add(answer, 'R', 1)
print("".join(answer))

Submission status: Wrong Answer

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

if dx >=0 and dy >=0:
    print("U"*dy+"R"*dx+"D"*dy+"L"*dx+"D"*1+"R"*(dx+1)+"U"*(dy+1)+"L"*1+"U"*1+"L"*dx+"D"*(dy+1)+"R")

elif dx < 0 and dy >=0:
    print("U"*dy+"L"*abs(dx)+"D"*dy+"R"*abs(dx)+"D"*1+"L"*(abs(dx)+1)+"U"*(dy+1)+"R"*1+"U"*1+"R"*abs(dx)+"D"*(dy+1)+"L")

elif dx >= 0 and dy <0:
    print("D"*abs(dy)+"R"*dx+"U"*abs(dy)+"L"*dx+"U"*1+"R"*(dx+1)+"D"*(abs(dy)+1)+"L"*1+"D"*1+"L"*dx+"U"*(abs(dy)+1)+"R")

else:
    print("D"*abs(dy)+"L"*abs(dx)+"U"*abs(dy)+"R"*abs(dx)+"U"*1+"L"*(abs(dx)+1)+"D"*(abs(dy)+1)+"R"*1+"D"*1+"R"*abs(dx)+"U"*(abs(dy)+1)+"L")

Submission status: Wrong Answer

Solution code:
import sys


def start_with(s):
    if s == '':
        print('YES')
        sys.exit(0)

    try:
        if s[0:5] == 'dream':
            start_with(s[5:])
        if s[0:7] == 'dreamer':
            start_with(s[7:])
        if s[0:5] == 'erase':
            start_with(s[5:])
        if s[0:6] == 'eraser':
            start_with(s[6:])
        return 
    except IndexError:
        return


sys.setrecursionlimit(1000000)
S = input()
start_with(S)
print('NO')

Submission status: Wrong Answer

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

first_U_times = ty - sy
for _ in range(first_U_times):
    ans.append('U')
first_R_times = tx - sx
for _ in range(first_R_times):
    ans.append('R')
for _ in range(first_U_times):
    ans.append('D')
for _ in range(first_R_times):
    ans.append('L')

ans.append('R')
for _ in range(first_U_times+1):
    ans.append('D')
for _ in range(first_R_times+1):
    ans.append('L')
ans.append('U')

ans.append('L')
for _ in range(first_U_times+1):
    ans.append('U')
for _ in range(first_R_times+1):
    ans.append('R')
ans.append('D')

ans = ''.join(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
sX,sY,tX,tY = list(map(int,input().split()))
ans = ""
a1 = 'U' * (tY-sY) + 'R' * (tX-sX)
a2 = 'D' * (tY-sY) + 'L' * (tX-sX)
a3 = "L" + "U" * (tX-sX+1) + "R" * (tY-sY+1) + "D"
a4 = "R" + "D" * (tY-sY+1) +"L" * (tX-sX+1) +"U"
print(a1+a2+a3+a4)

Submission status: Wrong Answer

Solution code:
sX,sY,tX,tY = list(map(int,input().split()))
ans = ""
a1 = (tX-sX) * "R" + (tY-sY) * "U"
a2 = (tX-sX) * "L" + (tY-sY) * "D"
a3 = "L" + "U" * (tX-sX+1) + "R" * (tY-sY+1) + "D"
a4 = "R" + "D" * (tY-sY+1) +"L" * (tX-sX+1) +"U"
print(a1+a2+a3+a4)

Submission status: Wrong Answer

Solution code:
X,Y,sX,sY = list(map(int,input().split()))
ans = ""
if sX-X>=0:
    if sY-Y>=0:
        ans += "R" * abs(X-sX)
        ans += "U" * abs(Y-sY)
        ans += "D" * abs(Y-sY)
        ans += "L" * abs(X-sX)
        ans += "R" * (abs(X-sX)+2)
        ans += "U" * (abs(Y-sY)+2)
        ans += "D" * (abs(Y-sY)+2)
        ans += "L" * (abs(X-sX)+2)
    else:
        ans += "R" * (abs(X-sX))
        ans += "D" * (abs(Y-sY))
        ans += "U" * (abs(Y-sY))
        ans += "L" * (abs(X-sX))
        ans += "R" * (abs(X-sX)+2)
        ans += "D" * (abs(Y-sY)+2)
        ans += "U" * (abs(Y-sY)+2)
        ans += "L" * (abs(X-sX)+2)
else:
    if sY-Y>=0:
        ans += "L" * abs(X-sX)
        ans += "U" * abs(Y-sY)
        ans += "D" * abs(Y-sY)
        ans += "R" * abs(X-sX)
        ans += "L" * (abs(X-sX)+2)
        ans += "U" * (abs(Y-sY)+2)
        ans += "D" * (abs(Y-sY)+2)
        ans += "R" * (abs(X-sX)+2)
    else:
        ans += "L" * abs(X-sX)
        ans += "U" * abs(Y-sY)
        ans += "D" * abs(Y-sY)
        ans += "R" * abs(X-sX)
        ans += "L" * (abs(X-sX)+2)
        ans += "U" * (abs(Y-sY)+2)
        ans += "D" * (abs(Y-sY)+2)
        ans += "R" * (abs(X-sX)+2)
print(ans)

Submission status: Wrong Answer

Solution code:
X,Y,sX,sY = list(map(int,input().split()))
ans = ""
ans += "U" * (abs(Y-sY)*2+2)
ans += "D" * (abs(Y-sY)*2+2)
ans += "R" * (abs(X-sX)*2+2)
ans += "L" * (abs(X-sX)*2+2)
print(ans)

Submission status: Wrong Answer

Solution code:
sx, sy, tx, ty = map(int, input().split())
distance_x, distance_y = tx-sx, ty-sy
x_now, y_now = sx, sy

#path1
for i in range(distance_y):
    print("U",end="")
for i in range(distance_x):
    print("R",end="")

#path2
for i in range(distance_y):
    print("D",end="")
for i in range(distance_x):
    print("L",end="")

#path3
print("L",end="")
for i in range(distance_y+1):
    print("U",end="")
for i in range(distance_x+1):
    print("R",end="")
print("D",end="")

#path4
print("R",end="")
for i in range(distance_y+1):
    print("D",end="")
for i in range(distance_x):
    print("L",end="")
print("U")

Submission status: Wrong Answer

Solution code:
from collections import deque
sx, sy, tx, ty = map(int,input().split())
start = (sx + 1000, sy + 1000)
goal = (tx + 1000, ty + 1000)

grid = [[0] * 2001 for i in range(2001)]
q = deque()
q.append(start)
grid[start[0]][start[1]] = ''

d = [(1,0, 'D'), (0, 1, 'R'), (-1, 0, 'U'), (0, -1, 'L')]
flag = 0
while q:
    x, y = q.popleft()
    if flag == 4:
        break
    for dx, dy, direction in d:
        nx = x + dx
        ny = y + dy
        if not(0 <= nx <= 2000 and 0 <= ny <= 2000):continue

        if (nx, ny) == goal:

            if flag % 2 == 0:
                grid[nx][ny] = grid[x][y] + direction
                flag += 1
            else:
                temp = grid[x][y] + direction
                grid[nx][ny] += temp[::-1]
                flag += 1

        if grid[nx][ny] != 0:continue
        grid[nx][ny] = grid[x][y] + direction
        q.append((nx, ny))

print(grid[goal[0]][goal[1]])

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()


def resolve():
    sx,sy,tx,ty=map(int,input().split())
    tate=ty-sy
    yoko=tx-sx

    for _ in range(tate):
        print('U',sep='',end='')
    for _ in range(yoko+1):
        print('R',sep='',end='')
    for _ in range(tate+1):
        print('D',sep='',end='')
    for _ in range(yoko+1):
        print('L',sep='',end='')
    for _ in range(1):
        print('U',sep='',end='')
    for _ in range(1):
        print('L',sep='',end='')
    for _ in range(tate+1):
        print('U',sep='',end='')
    for _ in range(yoko+1):
        print('R',sep='',end='')
    for _ in range(tate+1):
        print('D',sep='',end='')
    for _ in range(yoko):
        print('L',sep='')




resolve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    sx,sy,tx,ty=map(int,input().split())
    tate=ty-sy
    yoko=tx-sx

    for _ in range(tate):
        print('U',sep='')
    for _ in range(yoko+1):
        print('R',sep='')
    for _ in range(tate+1):
        print('D',sep='')
    for _ in range(yoko+1):
        print('L',sep='')
    for _ in range(1):
        print('U',sep='')
    for _ in range(1):
        print('L',sep='')
    for _ in range(tate+1):
        print('U',sep='')
    for _ in range(yoko+1):
        print('R',sep='')
    for _ in range(tate+1):
        print('D',sep='')
    for _ in range(yoko):
        print('L',sep='')




resolve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    sx,sy,tx,ty=map(int,input().split())
    tate=ty-sy
    yoko=tx-sx

    for _ in range(tate):
        print('U',sep='')
    for _ in range(yoko+1):
        print('U',sep='')
    for _ in range(tate+1):
        print('D',sep='')
    for _ in range(yoko+1):
        print('L',sep='')
    for _ in range(1):
        print('U',sep='')
    for _ in range(1):
        print('L',sep='')
    for _ in range(tate+1):
        print('U',sep='')
    for _ in range(yoko+1):
        print('R',sep='')
    for _ in range(tate+1):
        print('D',sep='')
    for _ in range(yoko):
        print('L',sep='')




resolve()

Submission status: Wrong Answer

Solution code:
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
s=""
if tx!=sx and ty!=sy:
  #内回り計算
  s+="R"*x
  s+="U"*y
  s+="L"*x
  s+="D"*y
  #外回り
  s+="L"
  s+="U"*(y+1)
  s+="R"*(x+1)
  s+="D"
  s+="R"
  s+="D"*(y+1)
  s+="L"*(x+2)
  s+="U"
elif tx==sx:
  s+="R"*x
  
  s+="D"+"L"*x+"U"
  
  s+="U"+"R"*x+"D"

  s+="R"
  s+="U"*2
  s+="L"*(x+2)
  s+="D"*2
  s+="R"
elif ty==sy:
  s+="U"*x
  s+="R"+"D"*x+"L"
  s+="L"+"U"*x+"R"
  s+="U"
  s+="R"*2
  s+="D"*(y+2)
  s+="L"*2
  s+="U"
print(s)