Huawei OD Computer Test Real Questions-Archaeologist-2023 OD Unified Examination (Paper C)

Topic description:

An archaeologist discovered a stone tablet, but unfortunately, it had been broken into multiple pieces when he found it. N neatly broken stone tablet fragments were found on the spot. In order to decipher the content of the stele, archaeologists hope to have a program that can help calculate the number of text combinations in the restored stele. Can you help?

Enter description:

Enter n in the first line, where n represents the number of stone tablet fragments.

The second line inputs the text content s on the stone tablet fragments in sequence, with a total of n groups.​​    

Output description:

Output the combination of stele words (arranged in ascending order), with no extra spaces at the end of the line.

Additional instructions:

If there are stele fragments with identical contents, the sequence change between the fragments will not affect the restored inscription content, that is, the position change between the same fragments will not affect the combination.

Example 1

enter:

3
a b c

Output:

abc
acb
bac
bca
cab
cba

illustrate:

When the content on the stele fragment is "a", "b", "c", the combination is "abc", "acb", "bac", "bca", "cab", "cba"

Example 2

enter:

3
a b a

Output:

aab
aba
baa

illustrate:

When the content on the stele fragment is "a", "b", "a", the possible combinations are "aab", "aba", "baa"

Example 3

enter:

3
a b ab

Guess you like

Origin blog.csdn.net/2301_76848549/article/details/135031974