(백준 15649)엔앤엠(11)(파이썬)
https://www.acmicpc.net/problem/15665 15665호: N과 M (11) 문제의 조건을 만족하는 일련의 숫자를 한 줄에 하나씩 인쇄합니다. 중복 시퀀스는 한 번 이상 인쇄해서는 안 되며 각 시퀀스는 공백으로 구분하여 인쇄해야 합니다. 시퀀스는 알파벳 오름차순으로 인쇄됩니다. www.acmicpc.net 백트래킹으로 해결 n,m = map(int,input().split()) input_lst=list(set(list(map(int,input().split())))) input_lst.sort() s=() def dfs(start): if(len(s)==m): print(‘ ‘.join(map(str,s))) return for i in range(len(input_lst)): s.append(input_lst(i)) dfs(start+1) s.pop() dfs(0)