forked from encrypted-def/basic-algo-lecture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path15666.cpp
More file actions
34 lines (31 loc) · 649 Bytes
/
15666.cpp
File metadata and controls
34 lines (31 loc) · 649 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
// Authored by : yongjunleeme
// Co-authored by : -
// http://boj.kr/801162160382436b971d8a4bbcec798a
#include <bits/stdc++.h>
using namespace std;
int arr[10];
int num[10];
int n, m;
void func(int k, int st){
if(k == m){
for(int i = 0; i < m; i++) cout << arr[i] << " ";
cout << "\n";
return;
}
int tmp = -1;
for(int i = st; i < n; i++){
if(num[i] != tmp){
arr[k] = num[i];
tmp = arr[k];
func(k+1, i);
}
}
}
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);
}