fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  4. typedef long long ll;
  5.  
  6. set<string> strs;
  7. void combine(string& n,int indx){
  8. if(indx==n.size()){
  9. strs.insert(n);
  10. return;
  11. }
  12. for (int i = indx; i < n.size(); i++) {
  13. swap(n[indx], n[i]);
  14. combine(n, indx + 1);
  15. swap(n[indx], n[i]);
  16. }
  17.  
  18. }
  19.  
  20.  
  21. int main() {
  22. FAST
  23. string n;
  24. cin >> n;
  25. combine(n,0);
  26. cout << strs.size() << "\n";
  27. for(const auto& s:strs){
  28. cout<< s << "\n";
  29. }
  30. // system("pause");
  31. return 0;
  32. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
1