Advertisement
sherry_ahmos

Untitled

Jan 31st, 2023
1,012
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <string.h>
  5. #include <math.h>
  6. #include <set>
  7. #include <bits/stdc++.h>
  8.  
  9. using namespace std;
  10.  
  11. #define ll long long
  12. #define cy cout << "YES\n"
  13. #define cn cout << "NO\n"
  14. #define nl "\n"
  15. #define fi first
  16. #define se second
  17. #define MOD 1000000007
  18. #define all(v) v.begin(), v.end()
  19. #define sz(s) s.size()
  20. #define f0r(j, n) for (ll i = j; i < n; i++)
  21. template <typename T = int>
  22. istream &operator>>(istream &in, vector<T> &v)
  23. {
  24.     for (auto &x : v)
  25.         in >> x;
  26.     return in;
  27. }
  28.  
  29. template <typename T = int>
  30. ostream &operator<<(ostream &out, const vector<T> &v)
  31. {
  32.     for (const T &x : v)
  33.         out << x << " ";
  34.     return out;
  35. }
  36.  
  37. void sherry()
  38. {
  39.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  40. #ifndef ONLINE_JUDGE
  41.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  42. #endif
  43. }
  44. /*
  45. int gcd(ll a, ll b)
  46. {
  47.     if (b == 0)
  48.         return a;
  49.     return (b, a % b);
  50. }
  51. */
  52. void solve()
  53. {
  54.     string s;
  55.     cin >> s;
  56.     vector<string> st;
  57.     for (int i = 0; i < (1 << sz(s)); i++)
  58.     {
  59.         string t = "";
  60.         for (int j = 0; j < sz(s); j++)
  61.         {
  62.             if (i & (1 << j))
  63.             {
  64.                 t += s[j];
  65.             }
  66.         }
  67.         if (!t.empty())
  68.         {
  69.             st.push_back(t);
  70.         }
  71.     }
  72.     sort(all(st));
  73.     for (auto &i : st)
  74.     {
  75.         cout << i << nl;
  76.     }
  77. }
  78. int main()
  79. {
  80.     sherry();
  81.     int t = 1;
  82.     // cin >> t;
  83.     while (t--)
  84.         solve();
  85.     return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement