СПОРТ
InterviewTime limit1sMemory limit1024 MB
Given up to seven distinct lowercase letters, print every permutation of them in lexicographic order, one permutation per line.
- Level
Easy3 of 10
- Topics
- Backtracking, Recursion, Sorting, Brute force
- Solved
- No attempts yet
Problem
At a national competition, each athlete has a single lowercase Latin letter embroidered on their shirt, and that letter identifies them. Different athletes have different letters embroidered.
Write a program sport that finds every possible ranking of the athletes and, for each ranking, prints the sequence of letters from their uniforms.
Input
The standard input contains lowercase Latin letters, each corresponding to a different athlete. There are no spaces between the letters.
Output
Print the possible rankings to the standard output, one per line. Do not put spaces between the letters. The lines must be printed in alphabetical order.
Constraints
The number of athletes is at least 3 and at most 7.