practivceAlgorithm/백준

[백준][Python] 22858 원상복구 (small)

findTheValue 2021. 8. 26. 14:09

그냥 D규칙에따라 거꾸로 보내면 된다.

 

import sys
input = sys.stdin.readline

N, K = map(int, input().split())
after_shuffle = list(map(int, input().split()))
D = list(map(int, input().split()))

for _ in range(K):
    tmp = [0]*N
    for i in range(N):
        tmp[D[i]-1] = after_shuffle[i]
    after_shuffle = tmp
print(*after_shuffle)