File tree Expand file tree Collapse file tree 2 files changed +6
-22
lines changed
백준/Silver/15663. N과 M (9) Expand file tree Collapse file tree 2 files changed +6
-22
lines changed Original file line number Diff line number Diff line change 1- import sys
2- input = sys .stdin .readline
1+ from itertools import permutations
32
4- n , m = map (int , input ().split ())
3+ N , M = map (int , input ().split ())
54nums = list (map (int , input ().split ()))
65nums .sort ()
7- res = list ()
8- visited = [False ] * n
96
10- def bt (depth ):
11- if depth == m :
12- print (* res )
13- return
14- prev = 0
15- for i in range (n ):
16- if not visited [i ] and prev != nums [i ]:
17- prev = nums [i ]
18- visited [i ] = True
19- res .append (prev )
20- bt (depth + 1 )
21- visited [i ] = False
22- res .pop ()
23-
24- bt (0 )
7+ for i in set (permutations (nums , M )):
8+ print (* i )
Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 112872 KB, 시간: 132 ms
7+ 메모리: 114504 KB, 시간: 124 ms
88
99### 분류
1010
1111백트래킹
1212
1313### 제출 일자
1414
15- 2025년 4월 7일 14:21:12
15+ 2025년 6월 20일 18:23:45
1616
1717### 문제 설명
1818
You can’t perform that action at this time.
0 commit comments