-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ15665_NM(11).cpp
More file actions
47 lines (42 loc) · 838 Bytes
/
BOJ15665_NM(11).cpp
File metadata and controls
47 lines (42 loc) · 838 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
37
38
39
40
41
42
43
44
45
46
47
//
// main.cpp
// BOJ15665_NM(11)
//
// Created by 신지식 on 2018. 9. 28..
// Copyright © 2018년 Shin Ji Sik. All rights reserved.
//
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int n, m;
vector<int> v, a;
set<vector<int>> s;
void dfs(int cnt){
if(cnt == m){
auto iter = s.find(a);
s.insert(a);
if(iter == s.end()){
for(int i = 0; i < m; i++)
printf("%d ", a[i]);
printf("\n");
}
return;
}
for(int i = 0; i < n; i++){
a.push_back(v[i]);
dfs(cnt + 1);
a.pop_back();
}
}
int main(){
cin >> n >> m;
for(int i = 0; i < n; i++){
int num;
cin >> num;
v.push_back(num);
}
sort(v.begin(), v.end());
dfs(0);
}