#C2947. Unique Permutations of a String

    ID: 46319 Type: Default 1000ms 256MiB

Unique Permutations of a String

Unique Permutations of a String

Given a string ( s ), output all unique permutations of its characters sorted in lexicographical order. In other words, generate every distinct arrangement of the characters in ( s ) and display them one per line in increasing lexicographical order.

For example, when ( s = \texttt{ABC} ), the expected output is:
ABC
ACB
BAC
BCA
CAB
CBA

inputFormat

A single string ( s ) consisting of uppercase English letters. The input is given via standard input (stdin).

outputFormat

Print each unique permutation of ( s ) on a separate line, sorted in lexicographical order. The output should be written to standard output (stdout).## sample

ABC
ABC

ACB BAC BCA CAB CBA

</p>