2056. Securing the Barn

单点时限: 2.0 sec

内存限制: 256 MB

Farmer John has installed a new security system on the barn and now must issue a valid password to the cows in the herd. A valid password consists of L (3 <= L <= 15) different lower-case characters (from the traditional latin character set ‘a’…’z’), has at least one vowel(‘a’, ‘e’, ‘i’, ‘o’, or ‘u’), at least two consonants (non-vowels),and has characters that appear in alphabetical order (i.e., ‘abc’ is valid; ‘bac’ is not).

Given a desired length L along with C lower-case characters, write a program to print all the valid passwords of length L that can be formed from those letters. The passwords must be printed in alphabetical order, one per line.

Construct your program to print no more then 25,000 passwords, even if more are valid.

输入格式

  • Line 1: Two space-separated integers, L and C

  • Line 2: C space-separated lower-case characters that are the set of characters from which to build the passwords

输出格式

  • Lines 1..?: Each output line contains a word of length L characters(and no spaces). The output lines must appear in alphabetical order. Stop your program after printing 25,000 lines.

样例

Input
4 6
a t c i s w
INPUT DETAILS:
Passwords of length 4 chosen from the given six characters
Output
acis
acit
aciw
acst
acsw
actw
aist
aisw
aitw
astw
cist
cisw
citw
istw

10 人解决,35 人已尝试。

19 份提交通过,共有 118 份提交。

7.7 EMB 奖励。

创建: 16 年,11 月前.

修改: 7 年,2 月前.

最后提交: 1 年,4 月前.

来源: USACO

题目标签