-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSA01024.cpp
More file actions
48 lines (46 loc) · 772 Bytes
/
Copy pathDSA01024.cpp
File metadata and controls
48 lines (46 loc) · 772 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
#include<bits/stdc++.h>
using namespace std;
int n, k;
int b[100];
vector<string> a;
void Try(int i)
{
for(int j = b[i-1] + 1; j<=n-k+i; j++)
{
b[i] = j;
if(i == k)
{
for(int l = 1; l <=k; l++)
{
cout << a[b[l]-1] << ' ';
}
cout << endl;
}
else
Try(i+1);
}
}
int main()
{
cin >> n >> k;
string tmp;
for(int i = 0; i<=n; i++)
{
cin >> tmp;
int check = 1;
for(auto j : a)
{
if(j == tmp)
{
check = 0;
}
}
if(check)
{
a.push_back(tmp);
}
}
n = a.size();
sort(a.begin(), a.end());
Try(1);
}