728x90
반응형
https://www.acmicpc.net/problem/15666
문제 해결
●아래 문제와 유사한 문제
https://thought-process-ing.tistory.com/90
●고른 수열이 비내림차순이다. (dfs를 쓸 때 i번째 원소를 가져왔으면 다음번에 i번째 이상의 원소를 가져와야한다.)
●오림차순으로 출력
CODE
import sys
input = sys.stdin.readline
def dfs(start, num):
if len(num) == m:
print(*num)
return
for i in range(start, len(A)):
num.append(A[i])
dfs(i, num)
num.pop()
if __name__=="__main__":
n, m = map(int, input().split())
A = list(set(list(map(int, input().split()))))
A.sort()
num = []
start = 0
dfs(start, num)
728x90
반응형
'알고리즘 > [python] 백준 BOJ' 카테고리의 다른 글
[python] 백준 10973 이전 순열 (0) | 2023.01.08 |
---|---|
[python] 백준 10972 다음 순열 (0) | 2023.01.07 |
[python] 백준 15665 N과 M (11) (1) | 2023.01.06 |
[python] 백준 9372 상근이의 여행 (1) | 2023.01.05 |
[python] 백준 15664 N과 M (10) (1) | 2023.01.05 |
댓글