-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathRotate.py
More file actions
29 lines (23 loc) · 783 Bytes
/
Copy pathRotate.py
File metadata and controls
29 lines (23 loc) · 783 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
'''
This simple solution will time out for Inputs 8-13: No additional constraints.
Refer to an efficient solution at http://www.usaco.org/current/data/sol_prob3_bronze_open23.html
'''
N, K, T = [int(x) for x in input().rstrip().split()]
A = [int(x) for x in input().rstrip().split()]
#print(f'{N=} {K=} {T=}')
#print(f'{A=}')
output = [i for i in range(N)]
def update_pos(output: list, A: list, N: int, K: int) -> list:
temp = output[A[K-1]]
for i in range(K-2,-1,-1):
src = A[i]
dst = A[i+1]
output[dst] = output[src]
output[A[0]] = temp
A = [(i+1)%N for i in A]
print(f'in update_pos {A=} {output=}')
return A
for _ in range(T):
A = update_pos(output, A, N, K)
output = [str(x) for x in output]
print(' '.join(output))