forked from encrypted-def/basic-algo-lecture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path15664.cpp
More file actions
36 lines (33 loc) · 790 Bytes
/
15664.cpp
File metadata and controls
36 lines (33 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Authored by : connieya
// Co-authored by : BaaaaaaaaaaarkingDog
// http://boj.kr/7c17e31c609d4010ad339cec1f7ed280
#include <bits/stdc++.h>
using namespace std;
int n, m;
int arr[10];
int num[10];
void func(int k, int st) {
if (k == m) {
for (int i = 0; i < m; ++i)
cout << arr[i] << ' ';
cout << '\n';
return;
}
int tmp = 0;
for (int i = st; i < n; ++i) {
if (tmp != num[i]) { // 이전 수열의 마지막 항과 새로운 수열의 마지막 항이 같으면 중복 수열
arr[k] = num[i];
tmp = arr[k];
func(k + 1, i + 1);
}
}
}
int main(void) {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < n; ++i)
cin >> num[i];
sort(num, num + n);
func(0, 0);
}