-
Notifications
You must be signed in to change notification settings - Fork 0
/
15665.cpp
44 lines (43 loc) · 808 Bytes
/
15665.cpp
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
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
int N, M;
vector<int> v;
void go(vector<int> &in)
{
if (v.size() == M)
{
for (auto it : v)
{
printf("%d ", it);
}
puts("");
return;
}
for (int i = 0; i < in.size(); i++)
{
v.push_back(in[i]);
go(in);
v.pop_back();
}
return;
}
int main()
{
cin >> N >> M;
int temp;
vector<int> input;
for (int i = 0; i < N; i++)
{
cin >> temp;
input.push_back(temp);
}
sort(input.begin(), input.end());
input.resize(unique(input.begin(), input.end()) - input.begin());
go(input);
return 0;
}