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

ans = ''
ans += 'R'*abs(diff_x) if diff_x>0 else 'L'*abs(diff_x) # 1
ans += 'U'*abs(diff_y+1) if diff_x>0 else 'D'*abs(diff_y+1) # 2
ans += 'R'*abs(diff_x) if diff_x<0 else 'L'*abs(diff_x) # 3
ans += 'U'*(abs(diff_y)+2) if diff_x<0 else 'D'*(abs(diff_y)+2) # 4
ans += 'R'*abs(diff_x+1) if diff_x>0 else 'L'*abs(diff_x+1) # 5
ans += 'U'*abs(diff_y+1) if diff_x>0 else 'D'*abs(diff_y+1) # 6
ans += 'R'*abs(diff_x+2) if diff_x<0 else 'L'*abs(diff_x+2) # 7
ans += 'U'*(abs(diff_y)) if diff_x<0 else 'D'*(abs(diff_y)) # 8
ans += 'R' if diff_x>0 else 'D' # 1

print(ans)
'''
coord = [sx, sy]
for i in ans:
  if i=='R':
    coord[0] += 1
  elif i=='L':
    coord[0] -= 1
  elif i=='U':
    coord[1] += 1
  elif i=='D':
    coord[1] -= 1  
  print(coord)
'''

Submission status: Wrong Answer

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

ans = ''
ans += 'R'*abs(diff_x) if diff_x>0 else 'L'*abs(diff_x) # 1
ans += 'U'*abs(diff_y+1) if diff_x>0 else 'D'*abs(diff_y+1) # 2
ans += 'R'*abs(diff_x) if diff_x<0 else 'L'*abs(diff_x) # 3
ans += 'U'*(abs(diff_y)+2) if diff_x<0 else 'D'*(abs(diff_y)+2) # 4
ans += 'R'*abs(diff_x+1) if diff_x>0 else 'L'*abs(diff_x+1) # 5
ans += 'U'*abs(diff_y+1) if diff_x>0 else 'D'*abs(diff_y+1) # 6
ans += 'R'*abs(diff_x+2) if diff_x<0 else 'L'*abs(diff_x+2) # 7
ans += 'U'*(abs(diff_y)+1) if diff_x<0 else 'D'*(abs(diff_y)+1) # 8
ans += 'R' if diff_x>0 else 'D' # 1

print(ans)

Submission status: Wrong Answer

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

ans = ''
ans += 'U'*abs(diff_x) if diff_x>0 else 'D'*abs(diff_x) # 1
ans += 'R'*abs(diff_y+1) if diff_x>0 else 'L'*abs(diff_y+1) # 2
ans += 'U'*abs(diff_x) if diff_x<0 else 'D'*abs(diff_x) # 3
ans += 'R'*(abs(diff_y)+2) if diff_x<0 else 'L'*(abs(diff_y)+2) # 4
ans += 'U'*abs(diff_x+1) if diff_x>0 else 'D'*abs(diff_x+1) # 5
ans += 'R'*abs(diff_y+1) if diff_x>0 else 'L'*abs(diff_y+1) # 6
ans += 'U'*abs(diff_x+2) if diff_x<0 else 'D'*abs(diff_x+2) # 7
ans += 'R'*(abs(diff_y)+1) if diff_x<0 else 'L'*(abs(diff_y)+1) # 8
ans += 'U' if diff_x>0 else 'D' # 1

print(ans)

Submission status: Wrong Answer

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


for _ in range(dx):
	res.append("U")
for _ in range(dy):
	res.append("R")
for _ in range(dx):
	res.append("D")
for _ in range(dy):
	res.append("L")

res.append("L")
for _ in range(dx+1):
	res.append("U")
for _ in range(dy+1):
	res.append("R")
res.append("D")

res.append("R")
for _ in range(dx+1):
	res.append("D")
for _ in range(dy+1):
	res.append("L")
res.append("U")
print("".join(res))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math

sys.setrecursionlimit(1000)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return [int(x) for x in input().split()]
MOD = 10**9 + 7

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

trace = ""

# 1
trace += 'R' * dx
trace += 'U' * dy

# 2
trace += 'L' * (-dx)
trace += 'D' * (-dy)

# 3
trace += 'D'
trace += 'R' * (dx + 1)
trace += 'U' * (dy + 1)
trace += 'L'

# 2
trace += 'U'
trace += 'L' * (-dx - 1)
trace += 'D' * (-dy - 1)
trace += 'R'

print(trace)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = input()
    print(" ".join(a.split(",")))
    return

#B
def B():
    k, s = LI()
    ans = 0
    for i in range(k + 1):
        for j in range(k + 1):
            if 0 <= s - (i + j) <= k:
                ans += 1
    print(ans)
    return

#C
def C():
    sx, sy, tx, ty = LI()
    UD = ("U", "D")
    LR = ("R", "L")
    ans = UD[sy > ty] * (abs(sy - ty)) + LR[sx > tx] * (abs(sx - tx))
    ans += UD[ty > sy] * (abs(sy - ty)) + LR[tx > sx] * (abs(sx - tx))
    ans += LR[tx > sx] + UD[sy > ty] * (abs(sy - ty) + 1) + LR[sx > tx] * (abs(sx - tx) + 1) + UD[ty > sy]
    ans += LR[sx > tx] + UD[ty > sy] * (abs(sy - ty)) + LR[tx > sx] * (abs(sx - tx)) + UD[sy > ty]
    print(ans)
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Wrong Answer

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

rangex = tx-sx
rangey = ty-sy
# 行ったりきたりで4回

for x in range(rangex):
  print("R", end="")
for y in range(rangey):
  print("U", end="")
# 帰り
for x in range(rangex):
  print("L", end="")
for y in range(rangey):
  print("D", end="")
  
print("D", end="")
for x in range(rangex + 1):
  print("R", end="")
for y in range(rangey):
  print("U", end="")
print("L", end="")
# 帰り
print("U", end="")
for x in range(rangex+1):
  print("L", end="")
for y in range(rangey):
  print("D", end="")
print("R", end="")

Submission status: Wrong Answer

Solution code:
x,y,xx,yy=map(int,input().split())
x=xx-x
y=yy-y
print(("R"*x)+("U"*y)+("L"*x)+("D"*(y+1))+("R"*x)+("U"*(y+1))+"LU"+("L"*x)+("D"*(y+1)))

Submission status: Wrong Answer

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

for i in range(tx-sx):
    print("R",end="")
for i in range(ty-sx):
    print("U",end="")
for i in range(tx-sx):
    print("L",end="")
for i in range(ty-sx):
    print("D",end="")

print("D",end="")
for i in range(tx-sx+1):
    print("R",end="")
for i in range(ty-sx+1):
    print("U",end="")
print("L",end="")

print("U",end="")
for i in range(tx-sx+1):
    print("L",end="")
for i in range(ty-sx+1):
    print("D",end="")
print("R")

Submission status: Wrong Answer

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

for i in range(tx-sx):
    print("U",end="")
for i in range(ty-sx):
    print("R",end="")
for i in range(tx-sx):
    print("D",end="")
for i in range(ty-sx):
    print("L",end="")

print("L",end="")
for i in range(tx-sx+2):
    print("U",end="")
for i in range(ty-sx+2):
    print("R",end="")
print("D",end="")

print("R",end="")
for i in range(tx-sx+2):
    print("D",end="")
for i in range(ty-sx+2):
    print("L",end="")
print("U")

Submission status: Wrong Answer

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

for i in range(tx-sx):
    print("R",end="")
for i in range(ty-sx):
    print("U",end="")
for i in range(tx-sx):
    print("L",end="")
for i in range(ty-sx):
    print("D",end="")
print("D",end="")
for i in range(tx-sx+2):
    print("R",end="")
for i in range(ty-sx+2):
    print("U",end="")
print("L",end="")
print("U",end="")
for i in range(tx-sx):
    print("L",end="")
for i in range(ty-sx):
    print("D",end="")
print("R")

Submission status: Wrong Answer

Solution code:
import numpy as np
# 座標を入力
sx, sy, tx, ty = map(int, input().split())
S = np.array([sx, sy])
T = np.array([tx, ty])

# 2点の最短経路を返す関数を定義（左右移動優先かつ方向転換1回のみ） 
def shortest_path(start, end):
    if start[0] <= end[0]:
        lr_path = "R" * (end[0] - start[0])
    else:
        lr_path = "L" * (start[0] - end[0])
    if start[1] <= end[1]:
        ud_path = "U" * (end[1] - start[1])
    else:
        ud_path = "D" * (start[1] - end[1])
    return lr_path + ud_path

# 点Sから点Tまでの経路（1回目）
path_1 = shortest_path(S, T)
# 点Tから点Sまでの経路（1回目）
path_2 = shortest_path(T, S)
# 点Sから点Tまでの経路（2回目）
path_3 = "D" + shortest_path(S + np.array([0, -1]), T + np.array([1, 0])) + "L"
# 点Tから点Sまでの経路（2回目）
path_4 = "L" + shortest_path(S + np.array([-1, 0]), T + np.array([0, 1])) + "D"
# 全経路を出力
print(path_1 + path_2 + path_3 + path_4)

Submission status: Wrong Answer

Solution code:
# ABC051C - Back and Forth
def main():
    sx, sy, tx, ty = list(map(int, input().rstrip().split()))
    X, Y = abs(sx - tx), abs(sy - ty)
    move = ""
    move += "U" * X + "R" * Y + "D" * X + "L" * Y
    move += "L" + "U" * (X + 1) + "R" * (Y + 1) + "D"
    move += "R" + "D" * (Y + 1) + "L" * (X + 1) + "U"
    print(move)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# 1往復目
for _ in range(ty-sy):
    print("U",end='')
for _ in range(tx-sx):
    print("R",end='')
for _ in range(ty-sy):
    print("D",end='')
for _ in range(tx-sx+1):
    print("L",end='')

# 2往復目
print("L",end='')
for _ in range(ty-sy+1):
    print("U",end='')
for _ in range(tx-sx+1):
    print("R",end='')
print("D",end='')
print("R",end='')
for _ in range(ty-sy+1):
    print("D",end='')
for _ in range(tx-sx+1):
    print("L",end='')
print("U",end='')
print()

Submission status: Wrong Answer

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

nx=tx-sx
ny=ty-sy

ans=""

R1="U"*ny + "R"*nx + "D"*ny + "L"*nx
R2="D" + "R"*(nx + 1) + "U"*(ny + 1) +"R" + "U" + "L"*(nx + 1) +"D"*(ny + 1) + "R"

print(R1+R2)

Submission status: Wrong Answer

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

nx=tx-sx
ny=ty-sy

ans=""

R1="U"*ny + "R"*nx + "D"*ny + "L"*nx
R2="D" + "R"*(nx + 1) + "U"*(ny + 2) + "L"*(nx + 2) +"D"*(ny + 1) + "R"

print(R1+R2)

Submission status: Wrong Answer

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

nx=tx-sx
ny=ty-sy

ans=""

R1="U"*ny + "R"*nx + "D"*ny + "L"*nx
R2="D" + "R"*(nx + 1) + "U"*(ny + 2) + "L"*(nx + 1) +"D"*(ny + 1) + "R"

print(R1+R2)

Submission status: Wrong Answer

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

ans = ""
X = tx - sx
Y = ty - sy

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

for i in range(Y+1):
    ans += "D"
for i in range(X+1):
    ans += "L"
ans += "U"

print(ans)

Submission status: Wrong Answer

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

x = tx - sy
y = ty - sy

if (y > 0) and (x > 0):
    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")

elif (y > 0) and (x < 0):
    print(("D" * y) + ("R" * x) + ("U" * y) + ("L" * (x + 1)) + ("D" * (y + 1)) + ("R" * (x + 1)) + "U" + "R"
          + ("U" * (y + 1)) + ("L" * (x + 1)) + "D")

elif (y < 0) and (x > 0):
    print(("U" * y) + ("L" * x) + ("D" * y) + ("R" * (x + 1)) + ("U" * (y + 1)) + ("L" * (x + 1)) + "D" + "L"
          + ("D" * (y + 1)) + ("R" * (x + 1)) + "U")

elif (y < 0) and (x < 0):
    print(("D" * y) + ("L" * x) + ("U" * y) + ("R" * (x + 1)) + ("D" * (y + 1)) + ("L" * (x + 1)) + "U" + "L"
          + ("U" * (y + 1)) + ("R" * (x + 1)) + "D")

else:
    if x == 0:
        if y > 0:
            print(("U" * y) + "R" + ("D" * y) + "LL" + ("U" * y) + "R" + "U" + "RR" + ("D" * (y+2)) + "LLU")
        else:
            print(("D" * y) + "R" + ("U" * y) + "LL" + ("D" * y) + "R" + "D" + "RR" + ("U" * (y+2)) + "LLD")

    if y == 0:
        if y > 0:
            print(("U" * y) + "L" + ("D" * y) + "RR" + ("U" * y) + "L" + "U" + "LL" + ("D" * (y+2)) + "RRU")
        else:
            print(("D" * y) + "L" + ("U" * y) + "RR" + ("D" * y) + "L" + "D" + "LL" + ("U" * (y+2)) + "RRD")

Submission status: Wrong Answer

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

x = tx - sy
y = ty - sy

if (y > 0) and (x > 0):
    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")

elif (y > 0) and (x < 0):
    print(("U" * y) + ("L" * x) + ("D" * y) + ("R" * (x + 1)) + ("U" * (y + 1)) + ("L" * (x + 1)) + "D" + "L"
          + ("D" * (y+1)) + ("R" * (x + 1)) + "U")

elif (y < 0) and (x > 0):
    print(("D" * y) + ("R" * x) + ("U" * y) + ("L" * (x + 1)) + ("D" * (y + 1)) + ("R" * (x + 1)) + "U" + "R"
          + ("U" * (y + 1)) + ("L" * (x + 1)) + "D")

elif (y < 0) and (x < 0):
    print(("D" * y) + ("L" * x) + ("U" * y) + ("R" * (x + 1)) + ("D" * (y + 1)) + ("L" * (x + 1)) + "U" + "L"
          + ("U" * (y + 1)) + ("R" * (x + 1)) + "D")

else:
    if x == 0:
        if y > 0:
            print(("U" * y) + "R" + ("D" * y) + "LL" + ("U" * y) + "R" + "U" + "RR" + ("D" * (y+2)) + "LLU")
        else:
            print(("D" * y) + "R" + ("U" * y) + "LL" + ("D" * y) + "R" + "D" + "RR" + ("U" * (y+2)) + "LLD")

    if y == 0:
        if y > 0:
            print(("U" * y) + "L" + ("D" * y) + "RR" + ("U" * y) + "L" + "U" + "LL" + ("D" * (y+2)) + "RRU")
        else:
            print(("D" * y) + "L" + ("U" * y) + "RR" + ("D" * y) + "L" + "D" + "LL" + ("U" * (y+2)) + "RRD")

Submission status: Wrong Answer

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

x = tx - sy
y = ty - sy

if (y > 0) and (x > 0):
    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")

elif (y > 0) and (x < 0):
    print(("U" * y) + ("L" * x) + ("D" * y) + ("R" * (x + 1)) + ("U" * (y + 1)) + ("L" * (x + 1)) + "D" + "L"
          + ("D" * (y+1)) + ("R" * (x + 1)) + "U")

elif (y < 0) and (x > 0):
    print(("D" * y) + ("R" * x) + ("U" * y) + ("L" * (x + 1)) + ("D" * (y + 1)) + ("R" * (x + 1)) + "U" + "R"
          + ("U" * (y + 1)) + ("L" * (x + 1)) + "D")

elif (y < 0) and (x < 0):
    print(("D" * y) + ("L" * x) + ("U" * y) + ("R" * (x + 1)) + ("D" * (y + 1)) + ("L" * (x + 1)) + "U" + "L"
          + ("U" * (y + 1)) + ("R" * (x + 1)) + "D")

Submission status: Wrong Answer

Solution code:

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

lst_A = []

if (sx < tx) and (sy < ty):
    for i in range(tx - sx):
        lst_A.append("R")
    for i in range(ty - sy):
        lst_A.append("U")
    for i in range(tx - sx):
        lst_A.append("L")
    for i in range(ty - sy):
        lst_A.append("D")
    lst_A.append("D")
    for i in range(tx - sx + 1):
        lst_A.append("R")
    for i in range(ty - sy + 1):
        lst_A.append("U")
    for i in range(tx - sx + 2):
        lst_A.append("L")
    for i in range(ty - sy):
        lst_A.append("D")
    lst_A.append("R")


print("".join(lst_A))

Submission status: Wrong Answer

Solution code:

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

lst_A = []

if (sx < tx) and (sy < ty):
    for i in range(tx - sx):
        lst_A.append("R")
    for i in range(ty - sy):
        lst_A.append("U")
    for i in range(tx - sx):
        lst_A.append("L")
    for i in range(ty - sy):
        lst_A.append("D")
    lst_A.append("D")
    for i in range(tx - sx + 1):
        lst_A.append("R")
    for i in range(ty - sy + 2):
        lst_A.append("U")
    for i in range(tx - sx + 2):
        lst_A.append("L")
    for i in range(ty - sy + 1):
        lst_A.append("D")
    lst_A.append("R")


print("".join(lst_A))

Submission status: Wrong Answer

Solution code:
# 最短距離は当然abs(sx-tx)回x方向とabs(sy-ty)回y方向
# 同じ座標の周囲4マスすべてを使うことになるのでそうする
# 位置関係が判明しているのを利用

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

Submission status: Wrong Answer

Solution code:
def vertical_move(move):
    if move >= 0:
        return "U" * move
    return "D" * (-move)

def horizontal_move(move):
    if move >= 0:
        return "R" * move
    return "L" * (- move)

def opposite_horizontal_to_vertical(sx, sy, tx, ty):
    ans = ""
    first_opposite = ""
    vertical = ""
    horizontal = ""
    last_opposite = ""
    if sx <= tx:
        first_opposite = "L"
        horizontal = horizontal_move(tx - sx + 1)
    else:
        first_opposite = "R"
        horizontal = horizontal_move(tx - sx - 1)
        
    if sy <= tx:
        last_opposite = "D"
        vertical = vertical_move(ty + 1 - sy)
    else:
        last_opposite = "U"
        vertical = vertical_move(ty - 1 - sy)
        
    return first_opposite + vertical + horizontal + last_opposite

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

ans = ""
ans += vertical_move(ty - sy)
ans += horizontal_move(tx - sx)
ans += vertical_move(sy - ty)
ans += horizontal_move(sx - tx)

ans += opposite_horizontal_to_vertical(sx, sy, tx, ty)
ans += opposite_horizontal_to_vertical(tx, ty, sx, sy)

print(ans)

Submission status: Wrong Answer

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

dx = tx - sx
dy = ty - sy

for _ in range(dx):
    print('R', end='')
for _ in range(dy):
    print('U', end='')
for _ in range(dx):
    print('L', end='')
for _ in range(dy):
    print('D', end='')

print('L', end='')
for _ in range(dy+1):
    print('U', end='')
for _ in range(dx+1):
    print('R', end='')
print('DR', end='')
for _ in range(dy+1):
    print('D', end='')
for _ in range(dx+1):
    print('L', end='')
print('R', end='')

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
"""考え方
1回目のt行きは、右行ったあと上
1回目のs行きは、左行ったあと下
2回目のt行きは、一回下行って、右行ったあと上、その後左
2回目のs行きは、一回上行って、左行ったあと下、その後右
"""
def solve():
    sx, sy, tx, ty = list(map(int, input().split()))
    ans = ""
    
    # 一回目のt行き
    ans += "R"*(tx-sx)
    ans += "U"*(ty-sy)

    if ty-sy == 0:
        # 一回目のs行き
        # 一旦上に回り込む
        ans += "U"
        ans += "L"*(tx-sx)
        ans += "D"

        # 二回目のt行き
        # 一旦下に行って回り込む
        ans += "D"
        ans += "R"*(tx-sx)
        ans += "U"

        # 二回目のs行き
        # 一旦右行って回り込む
        ans += "R"
        ans += "D"*2
        ans += "L"*(tx-sx+2)
        ans += "U"*2
        ans += "R"

    elif tx-sx == 0:
        # 一回目のs行き
        # 一旦左に行って回り込む
        ans += "L"
        ans += "D"*(ty-sy)
        ans += "R"

        # 二回目のt行き
        # 一旦右に行って回り込む
        ans += "R"
        ans += "D"*(ty-sy)
        ans += "L"

        # 二回目のs行き
        # 一旦上に行って回り込む
        ans += "U"
        ans += "L"*2
        ans += "D"*(ty-sy+2)
        ans += "R"*2
        ans += "U"
    else:
        # 一回目のs行き
        ans += "L"*(ty-sy)
        ans += "D"*(tx-sx)

        # 二回目のt行き
        ans += "D"
        ans += "R"*(tx-sx+1)
        ans += "U"*(ty-sy+1)
        ans += "L"

        # 二回目のs行き
        ans += "U"
        ans += "L"*(tx-sx+1)
        ans += "D"*(ty-sy+1)
        ans += "R"

    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
"""考え方
1回目のt行きは、右行ったあと上
1回目のs行きは、左行ったあと下
2回目のt行きは、一回下行って、右行ったあと上、その後左
2回目のs行きは、一回上行って、左行ったあと下、その後右
"""
def solve():
    sx, sy, tx, ty = list(map(int, input().split()))
    ans = ""
    
    # 一回目のt行き
    ans += "R"*(tx-sx)
    ans += "U"*(ty-sy)

    # 一回目のs行き
    ans += "L"*(ty-sy)
    ans += "D"*(tx-sx)

    # 二回目のt行き
    ans += "D"
    ans += "R"*(tx-sx+1)
    ans += "U"*(ty-sy+1)
    ans += "L"

    # 二回目のs行き
    ans += "U"
    ans += "L"*(tx-sx+1)
    ans += "D"*(ty-sy+1)
    ans += "R"

    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
sx, sy, tx, ty = [int(i) for i in input().split()]
i = sx
j = sy
while(i < tx):
  print("R", end = "")
  i += 1
while(j < ty):
  print("U", end = "")
  j += 1
while(i > sx):
  print("L", end = "")
  i -= 1
while(j > sy):
  print("D", end = "")
  j -= 1
i -= 1
print("L", end = "")
while(j < ty+1):
  print("U", end = "")
  j += 1
while(i < tx):
  print("R", end = "")
  i += 1
j -= 1
print("D", end = "")
i += 1
print("U", end = "")
while(j > sy-1):
  print("D", end = "")
  j -= 1
while(i > sx):
  print("L", end = "")
  i -= 1
j += 1
print("U", end = "")

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

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

ans = []
# go
way1 = ["U"] * (gy-sy) + ["R"] * (gx-sx)
#return
way2 = ["D"] * (gx-sx) + ["L"] * (gy-sy)

way3 = ["L"] + ["U"] * (gy-sy+1) + ["R"] * (gx-sx+1) + ["D"]
way4 = ["R"] + ["D"] * (gx-sx+1) + ["L"] * (gy-sy+1) + ["U"]
ans += way1 + way2 + way3 + way4

print("".join(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def func(a, b, x, y):
    ans = ''
    if x > a:
        ans += 'R' * (x - a)
    if x < a:
        ans += 'L' * (a - x)
    
    if y > b:
        ans += 'U' * (y - b)
    if y < b:
        ans += 'D' * (b - y)
    return ans
  
print('R' + func(sx + 1, sy, tx + 1, ty) + 'L' \
          + 'U' + func(tx, ty + 1, sx, sy + 1) + 'D' \
          + 'L' + func(sx - 1, sy, tx - 1, ty) + 'R' \
          + 'D' + func(tx, ty - 1, sx, sy - 1) + 'U')

Submission status: Wrong Answer

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

def func(a, b, x, y):
    ans = ''
    if x > a:
        ans += 'R' * (x - a)
    if x < a:
        ans += 'L' * (a - x)
    
    if y > b:
        ans += 'U' * (y - b)
    if y < b:
        ans += 'D' * (b - y)
    return ans
  
print('U' + func(sx + 1, sy, tx + 1, ty) + 'D' \
          + 'R' + func(tx, ty + 1, sx, sy + 1) + 'L' \
          + 'L' + func(sx - 1, sy, tx - 1, ty) + 'R' \
          + 'D' + func(tx, ty - 1, sx, sy - 1) + 'U')

Submission status: Wrong Answer

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

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

    xdiff = tx - sx
    ydiff = ty - sy

    for _ in range(xdiff):
        print('R', end = '')
    for _ in range(ydiff):
        print('U', end = '')

    for _ in range(xdiff):
        print('L', end = '')
    for _ in range(ydiff):
        print('D', end = '')

    print('L', end = '')
    for _ in range(ydiff):
        print('U', end = '')
    
    for _ in range(xdiff):
        print('R', end = '')
    
    print('D', end = '')

    print('R', end = '')

    for _ in range(ydiff):
        print('D', end = '')

    for _ in range(xdiff):
        print('L', end = '')
    
    print('U', end = '')
    

solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans="U"*y+"R"*x
ans+="D"*y+"L"*x

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

Submission status: Wrong Answer

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

dx = tx - sx
dy = ty - sy

result = ""
def move(r, u, l, d):
    return r * abs(dx) + u * abs(dy) + l * abs(dx) + d * abs(dy) + d + r * (abs(dx)+1) + u * (abs(dy)+1) + l + u + l * (abs(dx)+1) + d *(abs(dy)+1) + r

def horizen_move(r, u, l, d):
    return r * abs(dx+dy) + u + l * abs(dx+dy) + d * 2 + r * abs(dx+dy) + u + r + u * 2 + l * (abs(dx+dy) + 2) + d*2 + r

if dx > 0:
    if dy > 0:
        result = move("R", "U", "L", "D")
        
    elif dy < 0:
        result = move("R", "D", "L", "U")
    elif dy == 0:
        result = horizen_move("R", "U", "L", "D")
        
elif dx < 0:
    if dy > 0:
        result = move("L", "U", "R", "D")
    elif dy < 0:
        result = move("L", "D", "R", "U")
    elif dy == 0:
        result = horizen_move("L", "U", "R", "D")

else:
    if dy > 0:
        result = horizen_move("U", "R", "D", "L")
    elif dy < 0:
        result = horizen_move("D", "R", "U", "L")

Submission status: Wrong Answer

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

ans = ''

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

print(ans)

Submission status: Wrong Answer

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

firstgo = 'R'*(tx - sx) + 'U'*(ty - sy)
firstcome = 'L'*(tx-sx) + 'D'*(ty - sy)
secondgo = 'D'+'R'*(tx-sx+1) + 'U'*(ty-sy+1) + 'L'
secondcome = 'U' + 'L'*(tx-sx+1) + 'D'*(ty-sy+1) + 'R'
print(firstcome+firstcome+secondgo + secondcome)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x = tx - sx
y = ty -sy

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
sx, sy, tx, ty = map(int,input().split())
ans = []
firstup = (ty-sy)*['U']
firstright = (tx-sx)*['R']
firstdown = (ty-sy)*['D']
firstleft = (tx-sx)*['L']
second_offset = ['R']
secoudup = firstup+['U']
secoundright = firstright + ['R']
second_offset2 = ['D']
second_offset3 = ['R']
secounddown = firstdown +['D']
secondleft = firstleft + ['L']
second_offset4 = ['U']
ans = firstup+firstright+firstdown+firstleft+second_offset+secoudup+second_offset2+second_offset3+secounddown+secondleft+second_offset4
print(''.join(ans))

Submission status: Wrong Answer

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

ans="U"*y + "R"*x
ans+="D"*y + "L"*x

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

Submission status: Wrong Answer

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

ans="U"*y + "R"*x
ans+="D"*y + "L"*x

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

Submission status: Wrong Answer

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

ans="U"*x + "R"*y
ans+="D"*x + "L"*y

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

Submission status: Wrong Answer

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

ans="U"*x + "R"*y
ans+="D"*x + "L"*y

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

Submission status: Wrong Answer

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

ans="U"*x + "R"*y
ans+="D"*x + "L"*y

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

print(ans)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
ans = ""
ans += "L" + "U" * (y+1) + "R" * (x+1) + "D"
ans += "R" + "D" * (y+1) + "L" * x + "U"
ans += "U" * y + "R" * x
ans += "D" * y + "L" * x
print(ans)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
ans = ""
ans += "L" + "U" * y + "R" * (x+1) + "D"
ans += "R" + "D" * y + "L" * (x+1) + "U"
ans += "R" * x + "U" * y
ans += "L" * x + "D" * y
print(ans)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
ans = ""
ans += "L" + "U" * y + "R" * x + "D"
ans += "R" + "D" * y + "L" * x + "U"
ans += "R" * x + "U" * y
ans += "L" * x + "D" * y
print(ans)