#C8292. Unique Lexicographical Permutations (Excluding Original)
Unique Lexicographical Permutations (Excluding Original)
Unique Lexicographical Permutations (Excluding Original)
Given a string (s), your task is to compute all the unique permutations of (s) in lexicographical order, but you must exclude the permutation that is exactly the same as the original string (s).
For example, if (s = \texttt{abc}), the unique permutations in lexicographical order are:
(\texttt{abc},, \texttt{acb},, \texttt{bac},, \texttt{bca},, \texttt{cab},, \texttt{cba}). Since the original (s = \texttt{abc}) is excluded, the output would be:
(\texttt{acb},, \texttt{bac},, \texttt{bca},, \texttt{cab},, \texttt{cba}).
inputFormat
The input consists of a single string (s) provided via standard input. The string contains only printable characters without spaces.
outputFormat
Output all unique permutations of (s) in lexicographical order, each on a separate line, excluding the original string itself. If there are no permutations (i.e. when (s) has length 1 or all characters are identical), output nothing.## sample
abc
acb
bac
bca
cab
cba
</p>