#K63697. Taco Permutations

    ID: 31811 Type: Default 1000ms 256MiB

Taco Permutations

Taco Permutations

This problem requires you to generate and print all permutations of a given string with unique characters. You are expected to implement a function which reads a single string from standard input and prints every permutation of the string in a separate line.

The challenge tests your understanding of recursion and backtracking. Each permutation should be generated via a backtracking algorithm. The order of the printed permutations should follow the natural order generated by the recursive swapping method.

For example, given the string ABC, one valid order of outputs is:

ABC
ACB
BAC
BCA
CBA
CAB

Note: The exact order may vary depending on your implementation but it must list all the distinct permutations.

inputFormat

The input consists of a single line, which contains a string with unique characters for which you are to compute all the permutations.

Example Input:
ABC

outputFormat

Output all the permutations of the provided string, each printed on a new line in the order generated by your algorithm.

Example Output:
ABC
ACB
BAC
BCA
CBA
CAB
## sample
ABC
ABC

ACB BAC BCA CBA CAB

</p>