Permutation_Of_String

Sep 22nd, 2020
729
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include<bits/stdc++.h>
2. using namespace std;
3.
4. #define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
5. #define ll long long
6. #define ld long double
7. #define pb push_back
8. #define fe first
9. #define se second
10. #define nl "\n"
11. #define pp pair < ll , ll >
12. #define sz(x) (ll)x.size()
13. #define st(x) sort(x.begin(),x.end())
14. #define rst(x) sort(x.rbegin(), x.rend())
15. #define all(x) x.begin(),x.end()
16. long double pi = 3.14159265358979323;
17.
18. const double EPS = 1e-12;
19. const int N = 1e6 + 5;
20. //Just A Gentle Reminder about MOD
21. const int mod = 1e9 + 7;
22.
23. //print all permutation of a string with duplicates
24.
25. void permute(string &s , int l , int r){
26.         if(l == r){
27.             cout << s << nl;
28.             return ;
29.         }
30.         for(int i = l ; i <= r ; i++ ){
31.             swap(s[i] , s[l]);
32.             permute(s , l + 1 , r);
33.             swap(s[i],s[l]);
34.         }
35. }
36.
37. int main()
38. {
39.     fast;
40.     string s;
41.     cin >> s ;
42.     permute(s,0,s.size()-1);
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.     return 0;
67. //It's not end it yet
68. }
RAW Paste Data