-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4-1.py
44 lines (37 loc) · 762 Bytes
/
4-1.py
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
41
42
43
44
n = int(input())
a = input().split()
result = [1,1]
for i in range(len(a)):
if a[i] == 'R':
result[1] += 1
elif a[i] == 'L':
result[1] -= 1
elif a[i] == 'U':
result[0] -= 1
else:
result[0] +=1
if result[0]<1:
result[0] +=1
elif result[0]>5:
result[0] -= 1
elif result[1]<1:
result[1] +=1
elif result[1]>5:
result[1] -= 1
print(result)
'''
n = int(input())
a = input().split()
x,y = 1,1
dx = [0,0,-1,1]
dy = [-1,1,0,0]
types = ['L','R','U','D']
for plan in a:
for i in range(len(types)):
if plan == types[i]:
nx = x+dx[i]
ny = y + dy[i]
if nx <1 or ny>n or nx>n or ny<1:
continue
x,y = nx, ny
'''