-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicpc15666.cpp
More file actions
33 lines (31 loc) · 764 Bytes
/
icpc15666.cpp
File metadata and controls
33 lines (31 loc) · 764 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
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
void func(int start, int n, int remain, vector<int> &arr, vector<int> &num) {
if (!remain) {
for (int i : arr) cout << num[i] << ' ';
cout << '\n';
return;
}
for (int i = start; i < n; i++)
if (!i || num[i - 1] < num[i]) {
arr.push_back(i);
func(i, n, remain - 1, arr, num);
arr.pop_back();
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, m;
vector<int> arr, num;
cin >> n >> m;
arr.reserve(m);
num.resize(n);
for (int &k : num) cin >> k;
sort(num.begin(), num.end());
func(0, n, m, arr, num);
return 0;
}