https://www.acmicpc.net/problem/10974
https://github.com/stellaluminary/Baekjoon
from itertools import permutations
n = int(input())
for i in permutations([s for s in range(1,n+1)]):
print(*i)
백트래킹
n = int(input())
s = [i for i in range(1,n+1)]
t = []
def dfs(depth):
if depth == n:
print(*t)
return
for i in range(n):
if s[i] not in t:
t.append(s[i])
dfs(depth+1)
t.pop()
dfs(0)