#K51932. Lexicographic String Permutations

    ID: 29197 Type: Default 1000ms 256MiB

Lexicographic String Permutations

Lexicographic String Permutations

Given a string s, generate all possible permutations of its characters in lexicographic (dictionary) order. The input string is assumed to consist of distinct characters (although your solution should work for any string) and the output should list each permutation on a new line.

Note: The lexicographic order is defined by the standard order of characters. For example, for the input "abc", the lexicographically ordered permutations are:

abc
acb
bac
bca
cab
cba

inputFormat

The input consists of a single string s given via standard input.

outputFormat

Print all the permutations of the string s in lexicographic order. Each permutation should be output on a separate line.## sample

abc
abc

acb bac bca cab cba

</p>