[알고리즘/백준] 15654: N과 M(5)(python)

유현민·2022년 4월 25일
0

알고리즘

목록 보기
140/253

수를 받아서 정렬을 해야한다.
정렬 후 그 수로 백트래킹 실행

N, M = map(int, input().split())
t = list(map(int, input().split()))
t.sort()
a = []


def dfs():
    if len(a) == M:
        print(' '.join(map(str, a)))
        return
    for i in range(0, N):
        if t[i] not in a:
            a.append(t[i])
            dfs()
            a.pop()


dfs()
profile
smilegate megaport infra

0개의 댓글