-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
41 lines (39 loc) · 852 Bytes
/
Copy pathmain.cpp
File metadata and controls
41 lines (39 loc) · 852 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
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int l, c;
vector<char> a;
bool check(string password) {
int ja = 0;
int mo = 0;
for(char c : password) {
if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c== 'u')
mo ++;
else ja++;
}
return ja >= 2 && mo >= 1;
}
void solve(string password, int index) {
if(password.length() == l) {
if(check(password)) {
cout << password << '\n';
}
return;
}
if(index == a.size()) return;
solve(password+a[index], index+1);
solve(password, index+1);
}
int main() {
ios_base::sync_with_stdio(false);
cin >> l >> c;
a.resize(c);
for(int i=0; i<c; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
solve("", 0);
return 0;
}