본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 22858번 원상 복구 (small)

by 현장 2022. 5. 5.

-Code

n, k = map(int, input().split())
s = list(map(int, input().split()))
d = list(map(int, input().split()))

for _ in range(k):
    result = [0] * n
    for i in range(n):
        result[d[i] - 1] = s[i]
    s = result
print(*s)