-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1759.cpp
More file actions
73 lines (51 loc) · 1.16 KB
/
1759.cpp
File metadata and controls
73 lines (51 loc) · 1.16 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<cstring>
#include<math.h>
#include<queue>
#include<vector>
using namespace std;
int L, C;
char arr[15];
char aei[5] = { 'a','e','i','o','u'};
int visited[15];
int isAei[15];
int totalCount = 0;
void back(int idx, int aeiCount, int Count) {
if (Count == L) {
if (aeiCount < 1 || Count - aeiCount < 2)return;
for (int i = 0; i < 15; i++) {
if(visited[i]==1)cout << arr[i];
}
cout << endl;
}
else if (Count > L)return;
for (int i = idx + 1; i < C; i++) {
if (visited[i] == 1)continue;
visited[i] = 1;
if (isAei[i]) back(i, aeiCount+1, Count+1);
else back(i, aeiCount, Count+1);
visited[i] = 0;
}
}
int main(void)
{
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cin >> L >> C;
for (int i = 0; i < C; i++) {
cin >> arr[i];
}
sort(arr, arr + C);
for (int i = 0; i < C; i++) {
for (int j = 0; j < 5; j++) {
if (arr[i] == aei[j])isAei[i] = 1;
}
}
for (int i = 0; i < C; i++) {
visited[i] = 1;
if (isAei[i]) back(i, 1, 1);
else back(i, 0, 1);
visited[i] = 0;
}
}