(https://www.acmicpc.net/problem/15649))

checklist, 출력할 숫자 배열 result을 만든다.index가 0부터 1씩 증가하면서, m이 되는 순간 result에 저장된 요소들을 출력한다.import sys
n,m= map(int, sys.stdin.readline().rstrip().split())
check_list=[0]*(n+1)
result_list=[0]*(m)
def check(index,n,m):
    if index==m:
        for i in range(m):
            print(result_list[i],end=" ")
        print()
        return
    for i in range(1,n+1):
        if check_list[i]==1: #이전에 출력된 숫자이면 무시
            continue
        result_list[index]=i #해당 인덱스에 숫자 넣어줌
        check_list[i]=1      #출력된 숫자 체크
        check(index+1,n,m)   #다음숫자 출력
        check_list[i]=0      #초기화
check(0,n,m)