-
Notifications
You must be signed in to change notification settings - Fork 566
/
Copy path1759.cpp
47 lines (41 loc) · 906 Bytes
/
1759.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
45
46
47
// Authored by : yongjunleeme
// Co-authored by : -
// http://boj.kr/04b7346a15bd441fb7c815c008682893
#include <bits/stdc++.h>
using namespace std;
int l, c;
int arr[17];
char s[17];
bool isused[17];
bool aeiou(char t){
return t == 'a' || t == 'e' || t == 'i' || t == 'o' || t == 'u';
}
void func(int k, int st){
if(k == l){
bool flag = false;
int cnt1 = 0;
int cnt2 = 0;
for(int i = 0; i < l; i++){
if(aeiou(s[arr[i]])) cnt1++;
else cnt2++;
}
if(cnt1 >= 1 && cnt2 >= 2) flag = true;
if(flag){
for(int i = 0; i < l; i++)
cout << s[arr[i]];
cout << "\n";
}
}
for(int i = st; i < c; i++){
arr[k] = i;
func(k+1, i+1);
}
}
int main(void){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> l >> c;
for(int i = 0; i < c; i++) cin >> s[i];
sort(s, s+c);
func(0, 0);
}