Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Prepared by Ibrahim Mesecan.
Permutations
Question:
In mathematics, permutation relates to the rearrangment
of all the members of a set into some sequence or order.
Write a program that generates all the permutations of a set of
n people.
Input specification
You will be given an integer n. And in the following n lines
you will be given the names of n people where
0 ≤ n ≤ 8. Names contain only English uppercase or
lowercase characters.
Output specification
Show all possible rearrangements for this n people.
Show for every possible arrangment of n people in a line,
separated by spaces.
Sample Input I
3
Red
Green
Blue
|
Sample Input II
4
Anila
Erol
Bardhyl
Erisa
|
Sample Output I
Red Green Blue
Red Blue Green
Green Red Blue
Green Blue Red
Blue Red Green
Blue Green Red
|
Sample Output II
Anila Erol Bardhyl Erisa
Anila Erol Erisa Bardhyl
Anila Bardhyl Erol Erisa
Anila Bardhyl Erisa Erol
Anila Erisa Erol Bardhyl
Anila Erisa Bardhyl Erol
Erol Anila Bardhyl Erisa
Erol Anila Erisa Bardhyl
Erol Bardhyl Anila Erisa
Erol Bardhyl Erisa Anila
Erol Erisa Anila Bardhyl
Erol Erisa Bardhyl Anila
Bardhyl Anila Erol Erisa
Bardhyl Anila Erisa Erol
Bardhyl Erol Anila Erisa
Bardhyl Erol Erisa Anila
Bardhyl Erisa Anila Erol
Bardhyl Erisa Erol Anila
Erisa Anila Erol Bardhyl
Erisa Anila Bardhyl Erol
Erisa Erol Anila Bardhyl
Erisa Erol Bardhyl Anila
Erisa Bardhyl Anila Erol
Erisa Bardhyl Erol Anila
|
Для отправки решений необходимо выполнить вход.
|