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: Runtime Error

Solution code:
A, B, N = map(int, input().split())
behavior = input()

for b in behavior:
  if b == 'S':
    if A > 0:
      A -= 1
  elif b == 'C':
    if B > 0:
      B -= 1
  elif b == 'E':
    if not ((A == 0) and (B == 0)):
      if A >= B:
        A -= 1
      else:
        B -= 1
print(A)
print(B)

Submission status: Runtime Error

Solution code:
[sx, sy, tx, ty]=list(map(int,input().split()))
a1=["R"]*(tx-sx)+["U"]*(ty-sy)+["L"]*(tx-sx)+["D"]*(ty-sy)
a2=["D"]+["R"]*(tx-sx+1)+["U"]*(ty-sy+1)+["L"]+["U"]+["L"]*(tx-sx+1)+["D"]*(ty-sy+1)+["R"]
ans=a1+a2
for i in range(len(ans))
	print(ans[i],end=" ")

Submission status: Runtime Error

Solution code:
H,W,A,B = map(int, input().split())
MOD = 10 ** 9 + 7

N = H+W+1

def power(base, num):
    if num == 0:
        return 1
    elif num % 2==0:
        return power(base, num//2) **2 % MOD
    elif num==1:
        return base % MOD
    else:
        return power(base, num//2) **2 * base % MOD

fact = [0 for i in range(N)]
inv_fact = [0 for i in range(N)]

fact[0] = 1
for i in range(1, N):
    fact[i] = fact[i-1] * i % MOD
    
inv_fact[H+W] = power(fact[H+W], MOD-2)
for i in range(1, N):
    inv_fact[N-1-i] = inv_fact[N-i] * (N-i) % MOD

    
def comb(x,y):
    return (fact[x] * inv_fact[y])%MOD * inv_fact[x-y] % MOD

ans = 0

for i in range(1, W-B+1):
    ans += comb(H-A+B-2+i, H-A-1) * comb(A-1+W-B-i, A-1) % MOD
    ans %= MOD
print(ans%MOD)

Submission status: Runtime Error

Solution code:
def make_prime(n):
    prime = []
    temp = n
    for i in range(2, n):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            prime.append([i, cnt])
    if temp!=1:
        prime.append([temp, 1])
    if prime==[]:
        prime.append([n, 1])

    return prime


from collections import defaultdict
d=defaultdict(lambda :1)
num = int(input())
w=10**9+7
for i in range(2,num+1):
    prime_num_list = make_prime(i)
    for j in range(len(prime_num_list)):
        key = prime_num_list[j][0]
        d[key] += prime_num_list[j][1]
cnt=1
for val in d.values():
    cnt*=val
print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
sx,sy,tx,ty = [int(i) for i in 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"
ans += "R"
for i in range(ty-sy+1):
    ans += "D"
for i in range(tx-sx+1):
    ans += "L"
ans += "U"

print(ans==ex)

Submission status: Runtime Error

Solution code:
sx, sy, tx, ty = [int(x) for x in input().split()]
y = ty - sy
l = ["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("".join(l))

Submission status: Runtime Error

Solution code:
from sys import stdin
sx, sy, tx, ty = [int(x) for x in stdin().readline().rstrip().split()]
x = tx - sx
y = ty - sy
l = ["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("".join(l))

Submission status: Runtime Error

Solution code:
from sys import stdin
def main():
    sx, sy, tx, ty = [int(x) for x in stdin().readline().rstrip().split()]
    x = tx - sx
    y = ty - sy
    l = ["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("".join(l))
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
sx, sy, tx, ty = [int(x) for x in stdin().readline().rstrip().split()]
x = tx - sx
y = ty - sy
l = ["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("".join(l))

Submission status: Runtime Error

Solution code:
#include<iostream>

#define X 2
#define Y 0
using namespace std;

int main(){
    int sx,tx,sy,ty;
    int dis_x,dis_y;
    int abs_dis_x, abs_dis_y;
    cin >> sx >> sy >> tx >> ty;
    dis_x = tx - sx;
    dis_y = ty - sy;
    char code[5] = "UDRL";
    bool code_x,code_y;
    int i;
    code_x = 0;
    code_y = 0;
    for(i=0;i<dis_x;i++){
        cout << "R";
    }
    for(i=0;i<dis_y;i++){
        cout << "U";
    }
    for(i=0;i< dis_x;i++){
        cout << "L";
    }
    for(i=0;i< dis_y;i++){
        cout << "D";
    }
    
    cout << "D";
    for(i=0;i<abs_dis_x+1;i++){
        cout << "R";
    }
    for(i=0;i<abs_dis_y+1;i++){
        cout << "U";
    }
    cout << "L";
    
    cout << "U";
    for(i=0;i<abs_dis_x+1;i++){
        cout << "L";
    }
    for(i=0;i<abs_dis_y+1;i++){
        cout << "D";
    }
    cout << "R";
    
    cout << endl;
}

Submission status: Runtime Error

Solution code:
# 座標を入力
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: Runtime Error

Solution code:
# 座標を入力
sx, sy, tx, ty = map(int, input())
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[0] - start[0])
    else:
        ud_path = "D" * (start[0] - end[0])
    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: Runtime Error

Solution code:
K, S = map(int, input().split())

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i + j + k == S:
                cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
sx, sy, tx, ty = [int(i) for i in input().split()]
sx = i
sy = j
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: Runtime Error

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

ans="U"*b+"R"*a
ans+="D"*b+"L"*a

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

print(ans)

Submission status: Runtime Error

Solution code:
sx,sy,tx,ty=map(int,input().split())
w=tx-sx
h=ty-xy
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: Runtime Error

Solution code:
K, S = map(int, input().split())

count = 0
for x in range(0,K+1):
    for y in range(0,K+1):
        a = S-x-y
        if a <= K and a>= 0:
            count += 1
print (count)

Submission status: Runtime Error

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"*(x+1)
ans+="U"*(y+1)
ans+="L"

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

print(ans)

Submission status: Runtime Error

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: Runtime Error

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

dx = tx - sx
dy = ty - sy

p1 = dy * 'U' + dx * 'R'
p2 = dy * 'D' + dx * 'L'
p3 = 'D' + (dx + 1) * 'R' + \
	(dy + 1) * 'U' + 'L'
p4 = 'U' + (dx + 1) * 'L' + \
	(dy + 1) * 'D' + 'R'
  
print(p1 + p2 + p3 + p4)

Submission status: Runtime Error

Solution code:
0 0 1 2

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 1
if N % 2 == 0:
    
    for i in list(range(1, N, 2)):
        if A.count(i) != 2:
            ans = 0
            break
            
else:
    if A.count(0) == 1:
        for i in list(range(2, N, 2)):
            if A.count(i) != 2:
                ans = 0
                break
    else:
        ans = 0

if ans == 0:
    print(0)
else:
    print((2**(N//2))%(10**9+7))

Submission status: Runtime Error

Solution code:
# input
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('L')

for i in range(ty - sy + 1):
    print('U')

for i in range(tx - sx + 1):
    print('R')

print('D')

print('R')

for i in range(ty - sy + 1):
    print('D')

for i in range('tx - sx + 1'):
    print('L')

print('U')

Submission status: Runtime Error

Solution code:
import sys
2. 
3.stdin = sys.stdin
4.na = lambda: list(map(int, stdin.readline().split()))
5. 
6.k,s = na()
7.ans = 0
8.for x in range(k+1):
9.    for y in range(k+1):
10.        z = s - (x+y)
11.        if z >= 0 and z <= k:
12.            ans += 1
13.print(ans)

Submission status: Runtime Error

Solution code:
lis = list(map(int, input().split()))
a=lis[0], b=lis[1], c=lis[2], d=lis[3]
x=c-a, y=d-b

for i in range(x):
    print('R', end='')
for i in range(y):
    print('U', end='')
for i in range(x):
    print('L', end='')
for i in range(y+1):
    print('D', end='')
for i in range(x+1):
    print('R', end='')
for i in range(y+2):
    print('U', end='')
for i in range(x+2):
    print('L', end='')
for i in range(y+1):
    print('D', end='')
print('R',end='')

Submission status: Runtime Error

Solution code:
sx, sy, tx, ty = [int(x) for x in input().strip()]
# A = (sx,sy)   B = (tx,ty)
S = ''
def move(a,b):
    global x,y,S
    if a-x>0:
        for i in range(a-x):
            x+=1
            S += 'R'
    else:
        for i in range(x-a):
            x-=1
            S += 'L'
    if b-y>0:
        for j in range(b-y):
            y+=1
            S += 'U'
    else:
        for j in range(y-b):
            y-=1
            S += 'D'

x,y=sx,sy
move(tx,y)
move(x,ty)
y+=1
S += 'U'
move(sx-1,y)
move(x,sy)
x += 1
S += 'R'
y -= 1
S += 'D'
move(tx+1,y)
move(x,ty+1)
print(S)

Submission status: Runtime Error

Solution code:
ef route(sx, sy, tx, ty):
    dx = tx - sx
    dy = ty - sy
    dx2 = dx if dx >= 0 else -dx
    dy2 = dy if dy >= 0 else -dy
    buf = ""
    for i in range(dx2):
        if dx >= 0:
            buf += "L"
        else:
            buf += "R"
    for i in range(dy2):
        if dy >= 0:
            buf += "U"
        else:
            buf += "D"
    return buf

if __name__ == "__main__":
    sx, sy, tx, ty = [int(i) for i in input().split()]
    r1 = route(sx, sy, tx, ty) + route(tx, ty, sx, sy)
    r2 = "L" + route(sx-1, sy, tx, ty+1)\
             + "DR" + route(tx+1, ty, sx, sy-1) + "U"
    print(r1 + r2)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def col(a, x):
   if x > a:
      while x > a:
         print("R")
         a += 1
   else:
      while x < a:
         print("L")
         a -= 1

def row(b, y):
   if y > b:
      while y > b:
         print("U")
         a += 1
   else:
      while y < b:
         print("D")
         a -= 1

data = int(input().split())
a, b, x, y = data[0], data[1], data[2], data[3]
col(a, x)
row(b, y)
row(y, b)
col(x, a)
print("L")
row(b, y + 1)
col(a - 1, x)
print("D")
print("R")
row(y, b)
col(x + 1, a)

Submission status: Runtime Error

Solution code:
ret=''
for i in range(tx-sx):
    ret=ret+'U'
for i in range(ty-sy):
    ret=ret+'R'
for i in range(tx-sx):
    ret=ret+'D'
import sys
inp=sys.stdin.readline()
sx,sy,tx,ty=map(lambda x: int(x), inp.split(' '))
for i in range(ty-sy+1):
    ret=ret+'L'
for i in range(tx-sx+1):
    ret=ret+'U'
for i in range(ty-sy+1):
    ret=ret+'R'
ret=ret+'DR'
for i in range(tx-sx+1):
    ret=ret+'D'
for i in range(ty-sy+1):
    ret=ret+'L'
ret=ret+'U'

Submission status: Runtime Error

Solution code:
"U" * h + "R" * (w + 1) + "D" * (h + 1) + "L" * (w + 1)