-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUNO_icpc.py
70 lines (62 loc) · 2.19 KB
/
UNO_icpc.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#UNO
T=int(input())
current_player=1
direction=1
for i in range(T):
N, K = map(int, input().split())
history = input().strip()
#current_player=1
#direction=1
for i in history:
if i == 'U':
#current_player = (current_player + direction - 1) % N + 1
#current_player= (current_player) + 1*(direction)
if direction==1:
if current_player==1:
current_player=2
elif current_player==2:
current_player=3
elif current_player==3:
current_player=1
elif direction==-1:
if current_player==1:
current_player=3
elif current_player==2:
current_player=1
elif current_player==3:
current_player=2
elif i == 'S':
#current_player = (current_player + 2 * direction - 1) % N + 1
#current_player= (current_player) + 2*(direction)
if direction==1:
if current_player==1:
current_player=3
elif current_player==2:
current_player=1
elif current_player==3:
current_player=2
elif direction==-1:
if current_player==1:
current_player=2
elif current_player==2:
current_player=1
elif current_player==3:
current_player=2
elif i == 'R':
direction *= -1
#current_player = (current_player + direction - 1) % N + 1
if direction==1:
if current_player==1:
current_player=2
elif current_player==2:
current_player=3
elif current_player==3:
current_player=1
elif direction == -1:
if current_player==1:
current_player=3
elif current_player==2:
current_player=1
elif current_player==3:
current_player=2
print(current_player)