CSES - Creating Strings | Tạo xâu

View as PDF

Points: 1000 (p) Time limit: 1.0s Memory limit: 512M Input: stdin Output: stdout

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 \(n\). Each character is between a-z.

Output

  • First print an integer \(k\): the number of strings. Then print \(k\) lines: the strings in alphabetical order.

Constraints

  • \(1 \leq n \leq 8\)

Example

Sample input

aabac

Sample output

20  
aaabc  
aaacb  
aabac  
aabca  
aacab  
aacba  
abaac  
abaca  
abcaa  
acaab  
acaba  
acbaa  
baaac  
baaca  
bacaa  
bcaaa  
caaab  
caaba  
cabaa  
cbaaa


Comments


  • 0
    vietnammuonnam_mvn    6:34 p.m. 24 sep, 2024

    Code sai


    • -11
      peter    9:59 p.m. 20 feb, 2024

      This comment is hidden due to too much negative feedback. Click here to view it.

      1 reply

      • 1
        huyhau6a2    8:19 p.m. 10 aug, 2022

        memory bé quá admin ơi!