#P1030. 构造字符串 (Creating Strings)
构造字符串 (Creating Strings)
Source: CSES Problem Set (Task 1622)
Link: https://cses.fi/problemset/task/1622
Category: Introductory Problems
- Time limit: 1.00 s
- Memory limit: 512 MB
Given a string, your task is to generate all different strings that can be created using its characters.
Input
The only input line has a string of length . Each character is between a–z.
Output
First print an integer : the number of strings. Then print lines: the strings in alphabetical order.
Constraints
Example
Input:
aabac
Output:
20
aaabc
aaacb
aabac
aabca
aacab
aacba
abaac
abaca
abcaa
acaab
acaba
acbaa
baaac
baaca
bacaa
bcaaa
caaab
caaba
cabaa
cbaaa