CSES Solutions
#1622Introductory Problems

Creating Strings

View on CSES

Solution

1622-Creating_Strings.cpp
1#include<bits/stdc++.h>
2using namespace std;
3#define int long long
4signed main(){
5  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
6  string s; cin>>s;
7  sort(s.begin(),s.end());
8  map<string,bool> mp;
9  do{
10    mp[s]=1;
11  }while(next_permutation(s.begin(),s.end()));
12  cout<<mp.size()<<'\n';
13  for(auto&p:mp)
14    cout<<p.first<<'\n';
15  return 0;
16}

Editorial not yet generated for this problem. Run the editorial generation script to add hints and detailed explanations.