# 15654 n과m (5) 실버 3
def perm(level):
if level == m:
print(*path)
return
for i in range(n):
if visited[i]:continue
visited[i] = 1
path.append(arr[i])
perm(level+1)
path.pop()
visited[i] = 0
n,m = map(int,input().split())
arr = list(map(int,input().split()))
arr.sort()
path = []
visited = [0] * n
perm(0)
'알고리즘 문제풀이' 카테고리의 다른 글
백준 9012 괄호 Python 스택 실버4 (0) | 2024.03.26 |
---|---|
백준 18917 수열과 쿼리 38 Python 수학 구현 실버3 (0) | 2024.03.26 |
백준 2164 카드 2 Python 자료구조 큐 실버4 (0) | 2024.03.24 |
백준 16953 A -> B Python 그래프 BFS 실버2 (0) | 2024.03.23 |
백준 2178 미로 탐색 Python 실버 1 그래프, BFS (1) | 2024.03.22 |