-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSA01028.cpp
More file actions
55 lines (50 loc) · 851 Bytes
/
Copy pathDSA01028.cpp
File metadata and controls
55 lines (50 loc) · 851 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
48
49
50
51
52
53
54
55
#include <bits/stdc++.h>
using namespace std;
#define faster() ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
int n, k, ok, a[100];
void ktao(){
for(int i = 1; i <= k; i++){
a[i] = i;
}
}
void sinh(){
int i = k;
while(i >= 1 && a[i] == n - k + i){
i--;
}
if(i == 0){
ok = 0;
}
else {
a[i]++;
for(int j = i + 1; j <= k; j++){
a[j] = a[j - 1] + 1;
}
}
}
int main() {
faster();
int t;
cin >> t >> k;
int tmp[100];
ok = 1;
set<int> se;
for(int i = 1; i <= t; i++){
int x; cin >> x;
se.insert(x);
}
n = se.size();
int i = 1;
for(int x : se){
tmp[i++] = x;
}
ktao();
while(ok){
for(int i = 1; i <= k; i++){
cout << tmp[a[i]] << " ";
}
sinh();
cout << endl;
}
return 0;
}