-
Notifications
You must be signed in to change notification settings - Fork 0
/
GIFTSRC_T.py
52 lines (29 loc) · 1.3 KB
/
GIFTSRC_T.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
45
46
47
48
49
50
51
52
# cook your dish her
from sys import stdin
if __name__=='__main__':
t = int(stdin.readline())
for _ in range(t):
n = int(stdin.readline())
moves = stdin.readline()
moves_list = list(map(str, moves))
repeat = False
final_cell = [0,0]
x_axis = ['L', 'R']
y_axis = ['U', 'D']
prev_move = 0
for i in range(n):
repeat = False
if (prev_move in x_axis and moves_list[i] in x_axis) or (prev_move in y_axis and moves_list[i] in y_axis):
repeat = True
if not repeat:
if moves_list[i] == 'L':
final_cell[0] = final_cell[0] - 1
elif moves_list[i] == 'R':
final_cell[0] = final_cell[0] + 1
elif moves_list[i] == 'U':
final_cell[1] = final_cell[1] + 1
elif moves_list[i] == 'D':
final_cell[1] = final_cell[1] - 1
prev_move = moves_list[i]
# print(prev_move)
print(*final_cell)