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

유현민·2022년 4월 25일
0

알고리즘

목록 보기
141/253

현재 수를 주고 백트래킹 실행

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


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


dfs(0)
profile
smilegate megaport infra

0개의 댓글