|
#include <stdio.h>

int L, C;
char path[26], arr[26], map[256];

void dfs(int i, int vowels, int idx)
  {
 if (idx == L) {
if (vowels)
printf("%s\n", path);
return ;
}
 for ( ; i <= C - L + idx; i++) {
path[idx] = arr[i];
dfs(i + 1, vowels + (arr[i] == 'a' || arr[i] == 'e' ||
arr[i] == 'i' || arr[i] == 'o' ||
arr[i] == 'u'),
idx + 1);
}
}

int main()
  {
int i, j;
char str[8];

freopen("e:\\test\\in.txt", "r", stdin);

scanf("%d%d", &L, &C);
 for (i = 0; i < C; i++) {
scanf("%s", str);
map[str[0]]++;
}
j = 0;
for (i = 'a'; i <= 'z'; i++)
if (map[i])
arr[j++] = i;
path[L] = 0;
dfs(0, 0, 0);

return 0;
}
|