forked from encrypted-def/basic-algo-lecture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1759_1.cpp
34 lines (31 loc) · 783 Bytes
/
1759_1.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
// Authored by : BaaaaaaaaaaarkingDog
// Co-authored by : -
// http://boj.kr/700bd7f11e834635a055fdf0845f4409
#include <bits/stdc++.h>
using namespace std;
int l, c;
char s[20];
bool aeiou(char t){
return t == 'a' || t == 'e' || t == 'i' || t == 'o' || t == 'u';
}
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);
vector<int> brute(c);
for(int i = l; i < c; i++) brute[i] = 1;
do{
string ans;
int cnt1 = 0; // 모음의 수
for(int i = 0; i < c; i++){
if(brute[i] == 0){
ans += s[i];
if(aeiou(s[i])) cnt1++;
}
}
if(cnt1 < 1 || l - cnt1 < 2) continue;
cout << ans << '\n';
}while(next_permutation(brute.begin(), brute.end()));
}