#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
#define FAST_IO() \
{\
ios::sync_with_stdio(false);\
cin.tie(NULL); \
cout.tie(NULL); \
}\
vector<char> v;
int l, c;
void DFS(int now, string str = "", int consonant = 0, int vowel = 0)
{
char ch = v[now];
str.push_back(ch);
if (ch == 'a' ||
ch == 'e' ||
ch == 'i' ||
ch == 'o' ||
ch == 'u')
vowel++;
else
consonant++;
if (str.length() == l)
{
if (vowel >= 1 &&
consonant >= 2)
cout << str << '\n';
return;
}
for (int i = now + 1; i < c; i++)
DFS(i, str, consonant, vowel);
}
int main()
{
FAST_IO();
cin >> l >> c;
v.resize(c);
for (int i = 0; i < c; i++)
cin >> v[i];
sort(v.begin(), v.end());
for (int i = 0; i <= c - l; i++)
DFS(i);
return 0;
}
'코딩테스트 > 백준' 카테고리의 다른 글
[골4] 20040 - 사이클 게임 (0) | 2023.10.30 |
---|---|
[골4] 1405 - 미친 로봇 (0) | 2023.10.26 |
[골3] 2473 - 세 용액 (0) | 2023.10.23 |
[골3] 2623 - 음악프로그램 (0) | 2023.10.23 |
[골4] 1647 - 도시 분할 계획 (0) | 2023.10.23 |