뚜루리 2024. 10. 11. 00:00
728x90
320x100

문제 링크 : https://www.acmicpc.net/problem/10974

 

구현

from itertools import permutations

N = int(input())

for permutation in permutations(range(1, N + 1)):
    print(' '.join(map(str, permutation)))
  • 순열 알고리즘 사용.
728x90
320x100