-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC.py
More file actions
40 lines (30 loc) · 678 Bytes
/
C.py
File metadata and controls
40 lines (30 loc) · 678 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from collections import deque
sx, sy, tx, ty = map(int, input().split())
ans = ''
def move(right, up):
global ans
while right and up:
while up:
s = up.popleft()
ans += s
while right:
s = right.popleft()
ans += s
right = deque(['R']*(tx-sx))
up = deque(['U']*(ty-sy))
move(right, up)
left = deque(['L']*abs(sx-tx))
down = deque(['D']*abs(sy-ty))
move(left, down)
right = deque(['R']*(tx-sx+1))
up = deque(['U']*(ty-sy+1))
ans += 'L'
move(right, up)
ans += 'D'
left = deque(['L']*(abs(sx-tx)+1))
down = deque(['D']*(abs(sy-ty)+1))
ans += 'R'
move(left, down)
ans += 'U'
# print(len(ans))
print(ans)