while i < k: compare_list[i], compare_list[k] = compare_list[k], compare_list[i] i += 1 k -= 1
print(*compare_list)
------------메모리초과 import sys from itertools import permutations
input = sys.stdin.readline
N = int(input()) compare_list = list(map(int, input().split())) num_list = [i for i inrange(1, N + 1)]
perm_list = list(permutations(num_list)) for i inrange(len(perm_list)): iflist(perm_list[i]) == compare_list: if i==0: print(-1) else: for num in perm_list[i-1]: print(num, end=" ")