코테 대비 python/백준

[복습] 15649 n과 m 1

ylab 2023. 4. 17. 23:02

백트레킹은 어렵다리; 

n,m = map(int, input().split())

result = []

def dfs():
    if len(result)==m:

        print(' '.join(map(str,result)))
        return
    for i in range(1,n+1):
        if i not in result:
            result.append(i)
            dfs()
            result.pop()


dfs()