TopCoder

User's AC Ratio

100.0% (4/4)

Submission's AC Ratio

50.0% (4/8)

Tags

Description

桌上有10張牌,分別寫著數字0~9。

小明選了n張牌,想要排出一個n位數。

已知n的大小以及這n張牌為何的條件下,你能由小到大輸出小明所有可能排出的n位數嗎?

特別注意:012不是三位數

Input Format

輸入包含兩行,第一行為一正整數n,且n=3或4或5。

第二行有n個數字,代表小明選的牌。

Output Format

輸出的每行有一個數字,代表可能排出的其中一個n位數,請由小到大輸出,最後要換行。

Sample Input 1

3
2 3 1

Sample Output 1

123
132
213
231
312
321

Sample Input 2

3
2 0 1

Sample Output 2

102
120
201
210

Hints

Problem Source

NEOJ Problem 2024

Subtasks

No. Testdata Range Constraints Score
1 0 20
2 1 20
3 2 20
4 3 20
5 4 20

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 65536 1
1 1000 65536 65536 2
2 1000 65536 65536 3
3 1000 65536 65536 4
4 1000 65536 65536 5