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:
from sys import stdin
input=stdin.readline().rstrip().split()
print(input)
sx=int(input[0])
sy=int(input[1])
tx=int(input[2])
ty=int(input[3])

first=tx-sx
second=ty-sy

output=first*"R"+second*"U"+first*"L"+second*"D"+"D"+(first+1)*"R"+(second+1)*"U"+"L"+"U"+(first+1)*"L"+(second+1)*"D"+"R"
"""
output=None
output+=first*"R"
output+=second*"U"

output+=first*"L"
output+=second*"D"

output+="D"
output+=(first+1)*"R"
output+=(second+1)*"U"
output+="L"

output+="U"
output+=(first+1)*"L"
output+=(second+1)*"D"
output+="R"
"""
print(output)

Submission status: Wrong Answer

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

round1 = "R" * dx + "U" * dy + "L" * dx + "D" * dy
round2 = "L" + "U" * dy + "R" * dx + "D" + "R" + "D" * dy + "L" * dx + "U"

print(round1 + round2)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(sx, sy, tx, ty)

dif_x = abs(tx - sx)
dif_y = abs(ty - sy)


for i in range(dif_x):
    print("R" , end="")

for i in range(dif_y):
    print("U", end="")

for i in range(dif_x):
    print("L", end="")

for i in range(dif_y):
    print("D", end="")

#２周目

print("D", end="")
for i in range(dif_x+1):
    print("R", end="")

for i in range(dif_y+1):
    print("U", end="")

print("L", end="")

print("U", end="")

for i in range(dif_x+1):
    print("L", end="")

for i in range(dif_y+1):
    print("D", end="")

print("R")

Submission status: Wrong Answer

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

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

print(sx, sy, tx, ty)

dif_x = tx - sx
dif_y = ty - sy


for i in range(dif_x):
    print("R" , end="")

for i in range(dif_y):
    print("U", end="")

for i in range(dif_x):
    print("L", end="")

for i in range(dif_y):
    print("D", end="")

#２周目

print("D", end="")
for i in range(dif_x+1):
    print("R", end="")

for i in range(dif_y+1):
    print("U", end="")

print("L", end="")

print("U", end="")

for i in range(dif_x+1):
    print("L", end="")

for i in range(dif_y+1):
    print("D", end="")

print("R")

Submission status: Wrong Answer

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

if(((tx-sx)>=3)and((ty-sy)>=3)):
 #下ずれ廻り(S->T +1マス)
 ans += 'U'*(ty-sy-1)
 ans += 'R'*(tx-sx-1)
 ans += 'U'
 ans += 'R'*(tx-sx-1)
 #下ずれ廻り(T->S -1マス)
 ans += 'D'*(ty-sy)
 ans += 'L'*(tx-sx-1)
 ans += 'D'
 ans += 'L'*(tx-sx-1)
 ans += 'U'
 #上ずれ廻り(S->T +2マス)
 ans += 'L'
 ans += 'U'*(ty-sy)
 ans += 'R'*(tx-sx-1)
 ans += 'U'
 ans += 'R'*(tx-sx-1)
 ans += 'D'*(ty-sy)
 #上ずれ廻り(S->T -2マス)
 ans += 'L'*(tx-sx-1)
 ans += 'D'
 ans += 'L'
  
else:
 #内廻り(S->T)
 ans += 'U'*(ty-sy)
 ans += 'R'*(tx-sx)
 #内廻り(T->S)
 ans += 'D'*(ty-sy)
 ans += 'L'*(tx-sx)
 #外廻り(S->T)
 ans += 'L'*(tx-sx)
 ans += 'U'*(ty-sy+1)
 ans += 'R'*(tx-sx+1)
 ans += 'D'
 #外廻り(T->S)
 ans += 'R'*(tx-sx)
 ans += 'D'*(ty-sy+1)
 ans += 'L'*(tx-sx+1)
 ans += 'U'

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    X = list(map(int, input().split()))

    diffx = X[2] - X[0]
    diffy = X[3] - X[1]

    f1 = 'U' * diffy + 'R' * diffx 
    b1 = 'D' * diffy + 'L' * diffx
    f2 = 'L' + 'U' * (diffy + 1) + 'R' * (diffx + 1) + 'D'
    b2 = 'R' + 'D' * (diffy + 1) + 'L' * (diffx + 1) + 'U'

    return f1 + b2 + f2 + b2


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

Submission status: Wrong Answer

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

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

def main():
    sx, sy, tx, ty = [ int(ele) for ele in raw_input().split()]

    # 最短経路問題
    # 単純化のため、s を (0,0)へと正規化する
    tx = tx + abs(sx)
    ty = ty + abs(sy)
    sx, sy = [ 0, 0 ]

    # 最短経路は２つしかない。その次に最短となる経路をどの様に算出するか
    ans = ''

    
    # TODO: t が (0,1)のとき対応できるかどうか
    # 1st: s -> t 
    for ct in xrange(tx):
        ans = ans + 'R'

    for ct in xrange(ty):
        ans = ans + 'U'

    # 1st: t  -> s
    for ct in xrange(tx):
        ans = ans + 'L'

    for ct in xrange(ty):
        ans = ans + 'D'

    # 2nd: s -> t
    ans = ans + 'L'
    for ct in xrange(ty+1):
        ans = ans + 'U'

    for ct in xrange(tx):
        ans = ans + 'R'

    ans = ans + 'D'

    # 2nd: t -> s
    ans = ans + 'R'
    for ct in xrange(ty+1):
        ans = ans + 'D'

    for ct in xrange(tx+1):
        ans = ans + 'L'

    ans = ans + 'U'

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

def main():
    sx, sy, tx, ty = [ int(ele) for ele in raw_input().split()]

    # 最短経路問題
    # 単純化のため、s を (0,0)へと正規化する
    tx = tx + abs(sx)
    ty = ty + abs(sy)
    sx, sy = [ 0, 0 ]

    # 最短経路は２つしかない。その次に最短となる経路をどの様に算出するか
    ans = ''
    
    # TODO: t が (0,1)のとき対応できるかどうか
    # 1st: s -> t 
    for ct in xrange(tx):
        ans = ans + 'R'

    for ct in xrange(ty):
        ans = ans + 'U'

    # 1st: t  -> s
    for ct in xrange(tx):
        ans = ans + 'L'

    for ct in xrange(ty):
        ans = ans + 'D'

    # 2nd: s -> t
    ans = ans + 'L'
    for ct in xrange(ty+1):
        ans = ans + 'U'

    for ct in xrange(tx):
        ans = ans + 'R'

    ans = ans + 'D'

    # 2nd: t -> s
    ans = ans + 'R'
    for ct in xrange(ty):
        ans = ans + 'D'

    for ct in xrange(tx):
        ans = ans + 'L'

    ans = ans + 'U'

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

sx, sy, tx, ty = nm()

ans = ''

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

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

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from functools import reduce

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    sx, sy, tx, ty = (int(_) for _ in input().split())  
    sx = sx - sx
    tx = tx - sx
    sy = sy - sy
    ty = ty - sy
    
    print('R'*tx+'U'*ty + 'L'*tx+'D'*ty + 'L'+'U'*(ty+1)+'R'*(tx+1)+'D' + 'R'+'D'*(ty+1)+'L'*(tx+1)+'U')
    
if __name__ == '__main__':
    main()

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

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

Submission status: Wrong Answer

Solution code:
#n=int(input())
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#import math
#li=input().split()
#S=input()

lis=list(map(int,input().split()))

S=""
x=lis[2]-lis[0]
y=lis[3]-lis[1]
S+="R"*x
S+="U"*y
S+="L"*x
S+="D"*(y+1)
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: Wrong Answer

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

s = ''
dx = tx - sx
dy = ty - sy

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

print(s)

Submission status: Wrong Answer

Solution code:
n=list(map(int, input().split()))
a = ""
for i in range(n[2]-n[0]):
        a += "R"
for i in range(n[3]-n[1]):
        a += "U"
for i in range(n[2]-n[0]):
        a += "L"
for i in range(n[2]-n[0]):
        a += "D"
a += "D"
for i in range(n[2]-n[0]+1):
        a += "R"
for i in range(n[3]-n[1]+1):
        a += "U"
a += "LU"
for i in range(n[2]-n[0]+1):
        a += "L"
for i in range(n[3]-n[1]+1):
        a += "D"
a += "R"
print(a)

Submission status: Wrong Answer

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

ans = ""

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

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

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

Submission status: Wrong Answer

Solution code:
x,y,z,w = list(map(int, input().split()))

dx = z-x
dy = w-y

ans=''

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

print(ans)

Submission status: Wrong Answer

Solution code:
x,y,z,w = list(map(int, input().split()))

dx = z-x
dy = w-y

ans=''

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

print(ans)

Submission status: Wrong Answer

Solution code:
x,y,z,w = list(map(int, input().split()))

dx = z-x
dy = w-y

ans=''

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

print(ans)

Submission status: Wrong Answer

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

def main():
	sx, sy, tx, ty = map(int, input().split(" "))
	
	ans = []
	
	# 1往復目
	for _ in range(sx, tx+1):
		ans.append("R")
	for _ in range(sy, ty+1):
		ans.append("U")
	for _ in range(tx, sx-1, -1):
		ans.append("L")
	for _ in range(ty, sy-1, -1):
		ans.append("D")
		
	# 2往復目
	ans.append("D")
	for _ in range(sx, tx+2):
		ans.append("R")
	for _ in range(sy-1, ty+1):
		ans.append("U")
	ans.append("L")
	
	ans.append("U")
	for _ in range(tx, sx-2, -1):
		ans.append("L")
	for _ in range(ty+1, sy-1, -1):
		ans.append("D")
	ans.append("R")
	
	print("".join(ans))
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

dx=tx-sx
dy=ty-ty

result=[]
for i in range(dx):
  result.append("R")
for i in range(dy):
  result.append("U")
for i in range(dx):
  result.append("L")
for i in range(dy):
  result.append("D")

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

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

print(result,sep='')

Submission status: Wrong Answer

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

go = ""

aa = a
bb = b

while aa != c or bb != d:
    if abs(aa - c) != 0:
        if aa < c:
            aa += 1
            go += "R"
        else:
            aa -= 1
            go += "L"
    elif abs(bb - d) != 0:
        if bb < d:
            bb += 1
            go += "U"
        else:
            bb -= 1
            go += "D"

while aa != a or bb != b:
    if abs(aa - a) != 0:
        if aa < a:
            aa += 1
            go += "R"
        else:
            aa -= 1
            go += "L"
    elif abs(bb - b) != 0:
        if bb < b:
            bb += 1
            go += "U"
        else:
            bb -= 1
            go += "D"
print(go)

Submission status: Wrong Answer

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

go = ""

aa = a
bb = b

while aa != c and bb != d:
    if abs(aa - c) != 0:
        if aa < c:
            aa += 1
            go += "R"
        else:
            aa -= 1
            go += "L"
    elif abs(bb - d) != 0:
        if bb < d:
            bb += 1
            go += "U"
        else:
            bb -= 1
            go += "D"

while aa != a and bb != b:
    if abs(aa - a) != 0:
        if aa < a:
            aa += 1
            go += "R"
        else:
            aa -= 1
            go += "L"
    elif abs(bb - b) != 0:
        if bb < b:
            bb += 1
            go += "U"
        else:
            bb -= 1
            go += "D"
print(go)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

result = ''

# 1syuume
result += 'R'*abs(sx-tx)
result += 'U'*abs(sy-ty)
result += 'L'*abs(sx-tx)
result += 'D'*abs(sy-ty)

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

print(result)

Submission status: Wrong Answer

Solution code:
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
str=''
if x-y>0:
     str+='R'*(x-y)
     str+='RU'*y
     str+='L'
     str+='LD'*y
     str+='LU'
     str+='UR'*y+'R'+'RD'
     str+='RD'+'DL'*y+'LLU'
elif y-x>0:
     str+='U'*(y-x)
     str+='UR'*x
     str+='D'*(y-x)
     str+='DL'*x
     str+='LUU'+'UR'*x+'RD'+'RDD'+'DL'*x+'LU'
else:
     str+='UR'*x
     str+='D'+'DL'*(x-1)+'L'
     str+='LU'+'UR'*x+'RD'+'RDD'+'DL'*(x-1)+'LLU'
print(str)

Submission status: Wrong Answer

Solution code:
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
str=''
if x-y>0:
     str+='R'*(x-y)
     str+='RU'*y
     str+='L'*(x-y)
     str+='LD'*y
     str+='LU'
     str+='UR'*y+'RRD'
     str+='RD'+'DL'*y+'LLU'
elif y-x>0:
     str+='U'*(y-x)
     str+='UR'*x
     str+='D'*(y-x)
     str+='DL'*x
     str+='LUU'+'UR'*x+'RD'+'RDD'+'DL'*x+'LU'
else:
     str+='UR'*x
     str+='D'+'DL'*(x-1)+'L'
     str+='LU'+'UR'*x+'RD'+'RDD'+'DL'*x+'LLU'
print(str)

Submission status: Wrong Answer

Solution code:
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
str=''
if x-y>0:
     str+='R'*(x-y)
     str+='RU'*y
     str+='L'*(x-y)
     str+='LD'*y
     str+='LU'
     str+='UR'*y+'RD'
     str+='RD'+'DL'*y+'LU'
elif y-x>0:
     str+='U'*(y-x)
     str+='UR'*x
     str+='D'*(y-x)
     str+='DL'*x
     str+='LUU'+'UR'*x+'RD'+'RDD'+'DL'*x+'LU'
else:
     str+='UR'*x
     str+='D'+'DL'*(x-1)+'L'
     str+='LU'+'UR'*x+'RD'+'RDD'+'DL'*x+'LU'
print(str)

Submission status: Wrong Answer

Solution code:
import os
import math
INF, MOD = float("inf"), 1e9 + 7
MAX, MIN = -INF, INF
dx1, dy1, dx2, dy2 = [-1, 0, 1, 0], [0, -1, 0, 1], [-1, 0, 1, -1, 1, -1, 0, 1], [-1, -1, -1, 0, 0, 1, 1, 1]

def get_int():
    return int(input())

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

while(True):
    try:
        a, b, x, y = get_int_list()
        print('R' * (x - a) + 'U' * (y - b) + 'L' * (x - a) + 'D' * (y - b) + 'D' + 'R' * (x - a + 1) + 'U' * (y - b + 1) + "LU" + 'L' * (x - a + 1) + 'D' * (y - b + 1) + 'L')
    except EOFError:
        exit()

Submission status: Wrong Answer

Solution code:
a, b, c, d = list(map(int, input().split()))
pos1 = [a, b]
pos2 = [c, d]

ans = ''


def horizontal(xdiff, ydiff):
    ret = ''
    ret += 'R'*xdiff + 'U'*ydiff
    ret += 'L'*xdiff + 'D'*ydiff
    ret += 'D'+'R'*(1+xdiff)+'U'*(1+ydiff)+'L'
    ret += 'U'+'L'*(1+xdiff)+'D'*(1+xdiff)+'R'
    return ret


ans = horizontal(c-a, d-b)
print(ans)

Submission status: Wrong Answer

Solution code:
a, b, c, d = list(map(int, input().split()))
pos1 = [a, b]
pos2 = [c, d]

ans = ''


def horizontal(a, b, c, d, diff):
    ret = ''
    ret += a*diff
    ret += c+b*(diff)+d
    ret += d+a*(diff)+c
    ret += a+c*2+b*(2+diff)+d*2+a
    return ret


if pos1[0] == pos2[0]:
    if pos1[1] < pos2[1]:
        ans = horizontal('U', 'D', 'R', 'L', pos2[1] - pos1[1])
    else:
        ans = horizontal('D', 'U', 'R', 'L', pos1[1] - pos2[1])
    print()
elif pos1[1] == pos2[1]:
    if pos1[0] < pos2[0]:
        ans = horizontal('R', 'L', 'U', 'D', pos2[0]-pos1[0])
    else:
        ans = horizontal('L', 'R', 'U', 'D', pos1[0]-pos2[0])
else:
    print()

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,x,y = (int(i) for i in input().split())
height = x-a
width = y-b
keiro1= 'L'+'U'*(height+1)+'R'*(width+1)+'D'
keiro2= 'L'*width+'D'*height
keiro3= 'R'*width+'U'*height
keiro4= 'R'+'D'*(height+1)+'L'*(width+1)+'U'
ans = keiro1+ keiro2+keiro3+keiro4


print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 051 C
sx, sy, tx, ty = [int(a) for a in input().split()]
#print(sx, sy, tx, ty)#
seq = ['U','R','D','L','U','R','D','R','D','L','U']
if tx-sx>0: 
    r = 'R'
    l = 'L'
else:
    r = 'L'
    l = 'R'
if ty-sy>0: 
    u = 'U'
    d = 'D'
else:
    u = 'D'
    d = 'U'
x = abs(tx-sx)
if x==0: x = 1 
y = abs(ty-sy)
if y==0: y = 1 
seqPtn = [u, r, d, l, l, u, r, u, r, d, r, d, l, d, l, u]
cntPtn = [y, x, y, x, 1, y, 1, 1, x, 1, 1, y, 1, 1, x, 1]
for i in range(len(seqPtn)):
    print(seqPtn[i]*cntPtn[i], end='')

Submission status: Wrong Answer

Solution code:
# 051 C
sx, sy, tx, ty = [int(a) for a in input().split()]
print(sx, sy, tx, ty)#
seq = ['U','R','D','L','U','R','D','R','D','L','U']
if tx-sx>0: 
    r = 'R'
    l = 'L'
else:
    r = 'L'
    l = 'R'
if ty-sy>0: 
    u = 'U'
    d = 'D'
else:
    u = 'D'
    d = 'U'
x = abs(tx-sx)
if x==0: x = 1 
y = abs(ty-sy)
if y==0: y = 1 
seqPtn = [u, r, d, l, l, u, r, u, r, d, r, d, l, d, l, u]
cntPtn = [y, x, y, x, 1, y, 1, 1, x, 1, 1, y, 1, 1, x, 1]
for i in range(len(seqPtn)):
    print(seqPtn[i]*cntPtn[i], end='')

Submission status: Wrong Answer

Solution code:
x1,y1,x2,y2 = map(int ,input().split())
x = x2 - x1
y = y2 - y1
ans = ''
a = 'U'
b = 'D'
c = 'R'
d = 'L'


for _ in range(y):
    ans += a
for _ in range(x):
    ans += c
for _ in range(y):
    ans += b
for _ in range(x) :
    ans += d
ans += d
for _ in range(y + 1):
    ans += a
for _ in range(x +1):
    ans += c
ans += b
ans += c
for _ in range(y + 1):
    ans += b
for _ in range(x + 1):
    ans += d
print(ans)

Submission status: Wrong Answer

Solution code:
sx,sy,tx,ty = map(int, input().split())
x = tx-sx
y = ty-sy
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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
sx, sy, tx, ty = map(int, input().split())
nsx, nsy = sx, sy
while nsy < ty:
    nsy += 1
    print("U", end = "")
while nsx < tx:
    nsx += 1
    print("R", end = "")
while nsy >= sy:
    nsy -= 1
    print("D", end="")
while nsx > sx:
    nsx -= 1
    print("L", end = "")
nsy += 1
print("U", end = "")
nsx -= 1
print("L", end = "")
while nsy <= ty:
    nsy += 1
    print("U", end = "")
while nsx < tx:
    nsx += 1
    print("R", end = "")
while nsy > sy:
    nsy -= 1
    print("D", end="")
while nsx > sx:
    nsx -= 1
    print("L", end = "")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    sx, sy, tx, ty = list(map(int, input().split()))
    dx = sx - tx
    dy = sy - ty
    ans = ''
    # 行き1
    ans += 'U' * dy + 'R' * dx
    # 帰り1
    ans += 'D' * dy + 'L' * dx
    # 行き2
    ans += 'L' + 'U' * (dy + 1) + 'R' * (dx + 1) + 'D'
    # 帰り2
    ans += 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U'
    # 答え
    print(ans)
    

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
a = input().split(" ")
sx = int(a[0])
sy = int(a[1])
gx = int(a[2])
gy = int(a[3])
ar = []
for b in range(gy - sy):
    ar.append("U")
for c in range(gx - sx):
    ar.append("R")
for d in range(gy - sy):
    ar.append("D")
for e in range(gx - sy + 1):
    ar.append("L")
for f in range(gy - sy + 1):
    ar.append("U")
for g in range(gx - sx + 1):
    ar.append("R")
ar.append("D")
ar.append("R")
for h in range(gy - sy + 1):
    ar.append("D")
for i in range(gx - sx + 1):
    ar.append("L")
ar.append("U")
print("".join(ar))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

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

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

print S

Submission status: Wrong Answer

Solution code:
sx, sy, tx, ty = map(int, input().split())
ans1 = "R"*(tx-sx) + "U"*(ty-sy)
ans2 = "L"*(tx-sx) + "D"*(ty-sy)
ans3 = "D" + "R"*(tx-sx+1) + "U"*(ty-sy+1)
ans4 = "U" + "L"*(tx-sx+1) + "D"*(ty-sy+1)

print(ans1+ans2+ans3+ans4)

Submission status: Wrong Answer

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

visited = set([(sx, sy)])

steps = abs(sx - tx) + abs(sy - ty)
ans = ""
pos = (sx, sy)
for i in range(steps):
    if pos[1] == ty:
        ans += "R"
        pos = (pos[0]+1, pos[1])
    else:
        ans += "U"
        pos = (pos[0], pos[1]+1)
    visited.add(pos)

visited.remove((sx, sy))
for i in range(steps):
    next_pos = (pos[0]-1, pos[1])
    if pos[1] == sy and next_pos not in visited:
        ans += "L"
        pos = (pos[0]-1, pos[1])
    else:
        ans += "D"
        pos = (pos[0], pos[1]-1)
    visited.add(pos)
    
ans += "L"
pos = (pos[0]-1, pos[1])
visited.add(pos)

visited.remove((tx, ty))
for i in range(steps*2): # 多めに
    next_pos = (pos[0]+1, pos[1])
    if pos == (tx, ty+1):
        ans += "D"
        pos = (pos[0], pos[1]-1)
        break
    else:
        if next_pos not in visited:
            ans += "R"
            pos = (pos[0]+1, pos[1])
        else:
            ans += "U"
            pos = (pos[0], pos[1]+1)
    visited.add(pos)
    
    
ans += "R"
pos = (pos[0]+1, pos[1])
visited.add(pos)

visited.remove((sx, sy))
for i in range(steps*2): # 多めに
    next_pos = (pos[0]-1, pos[1])
    if pos == (sx, sy-1):
        ans += "U"
        pos = (pos[0], pos[1]+1)
        break
    else:
        if next_pos not in visited:
            ans += "L"
            pos = (pos[0]-1, pos[1])
        else:
            ans += "D"
            pos = (pos[0], pos[1]-1)
    visited.add(pos)
    
print(ans)
# print(visited)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/python
# Back and Forth

"""
    −1000≦sx<tx≦1000
    −1000≦sy<ty≦1000
    sx,sy,tx,ty
    は整数である。
"""

test_mode = False

sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy
abs_dx = abs(dx)
abs_dy = abs(dy)

if test_mode:
    print('dx = {}'.format(dx))
    print('dy = {}'.format(dy))
    print('abs_dx = {}'.format(abs_dx))
    print('abs_dy = {}'.format(abs_dy))


def course_type(x, y):
    """
    x, y について
        0: x,y 両方が でない
        1: x   だけが 0
        2: y   だけが 0
        3: x,y 両方が 0
    を返す。入力は絶対値でよろしく。
    """
    if x != 0 and y != 0:
        return 0
    if x == 0 and y != 0:
        return 1
    if x != 0 and y == 0:
        return 2
    return 3


def course_temp(x, y):
    """
    とりあえず (0, 0)→(x, y) の2往復のしかたを返す関数。
    x,y >= 0 とすること。※第1象限で考えるため
    """

    s = ''
    flag = course_type(x, y)

    if flag == 0: # 2点が線分上にない場合
        # ここから 1往復目
        for _ in range(x):
            s += 'R'
        for _ in range(y):
            s += 'U'
        for _ in range(x):
            s += 'L'
        for _ in range(y):
            s += 'D'
        # ここまで 1往復目
        # ここから 2往復目
        s += 'U'
        for _ in range(x+1):
            s += 'R'
        for _ in range(y+1):
            s += 'U'
        s += 'L'
        s += 'U'
        for _ in range(x+1):
            s += 'L'
        for _ in range(y+1):
            s += 'D'
        s += 'R'
        # ここまで 2往復目

    elif flag == 1:
        # ここから 1往復目
        for _ in range(y+1):
            s += 'U'
        s += 'L'
        s += 'L'
        for _ in range(y+2):
            s += 'D'
        s += 'R'
        s += 'R'
        s += 'U'
        # ここまで 1往復目
        # ここから 2往復目
        s += 'R'
        for _ in range(y):
            s += 'U'
        s += 'L'
        s += 'L'
        for _ in range(y):
            s += 'D'
        s += 'R'
        # ここまで 2往復目

    elif flag == 2:
        # ここから 1往復目
        for _ in range(y+1):
            s += 'R'
        s += 'U'
        s += 'U'
        for _ in range(y+2):
            s += 'L'
        s += 'D'
        s += 'D'
        s += 'R'
        # ここまで 1往復目
        # ここから 2往復目
        s += 'D'
        for _ in range(y):
            s += 'R'
        s += 'U'
        s += 'U'
        for _ in range(y):
            s += 'L'
        s += 'D'
        # ここまで 2往復目

    else:
        pass

    return s


def convert(s):
    """
    dx, dy の符号に応じて 文字列s を変換して返す関数
    """
    if dx >= 0:
        pass
    else:
        s.translate(str.maketrans('RL', 'LR', )) # x方向の移動を反転
    if dy >= 0:
        pass
    else:
        s.translate(str.maketrans('UD', 'DU', )) # y方向の移動を反転

    return s


def main():
    """
    全体の処理を実行する関数
    """
    course = course_temp(abs_dx, abs_dy)
    if test_mode:
        print('course:', course)

    course = convert(course)
    if test_mode:
        print('course:', course)
    print(course)


if __name__ == '__main__':
    main()


"""
参考
    Pythonで文字列を置換（replace, translate, re.sub, re.subn）
    https://note.nkmk.me/python-str-replace-translate-re-sub/
"""

Submission status: Wrong Answer

Solution code:
x1, y1, x2, y2 = map(int, input().split())
x = x2-x1
y = y2-y1
s = "R"*x + "U"*(y+1) + "L"*x + "D"*(y+2) + "R"*(x+1) + "U"*(y+1) + "L"*(x+2) + "D"*y + "R"
print(s)

Submission status: Wrong Answer

Solution code:

sx, sy, tx, ty = map(int, input().split())
ans_list = []
for i in range(tx - sx):
    ans_list.append("R")
for j in range(ty-sy):
    ans_list.append("U")
for i in range(tx - sx):
    ans_list.append("L")
for j in range(ty-sy):
    ans_list.append("D")
ans_list.append("D")
for i in range(tx - sx + 1):
    ans_list.append("R")
for j in range(ty-sy + 1):
    ans_list.append("U")
ans_list.append("L")
ans_list.append("U")
for i in range(tx - sx + 1):
    ans_list.append("L")
for j in range(ty-sy + 1):
    ans_list.append("D")
ans_list.append("L")
print("".join(ans_list))