728x90
반응형
단순한 백트래킹 문제이다.
def dfs(depth):
if depth == 6:
print(*li)
return ;
for i in range(n):
if check[i]:
continue
li.append(nums[i])
check[i] = 1
dfs(depth+1)
li.pop()
for j in range(i+1, n):
check[j] = 0
while 1:
t = list(map(int, input().split()))
n, nums = t[0], t[1:]
if n == 0:
break
li = []
check = [0]*n
dfs(0)
print()
728x90
반응형
'Agorithm > 백준 알고리즘' 카테고리의 다른 글
백준 알고리즘 21867번 Java Bitecode(python) (0) | 2021.06.06 |
---|---|
백준 알고리즘 21866번 추첨을 통해 커피를 받자(python) (0) | 2021.06.06 |
백준 알고리즘 1238번 파티(python) (0) | 2021.04.10 |
백준 알고리즘 1715번 카드 정렬하기(python) (0) | 2021.04.07 |
백준 알고리즘 2075번 N번째 큰 수(python) (0) | 2021.04.07 |