habiba3azb

Untitled

Oct 15th, 2022
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.92 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <iomanip>
  3. #include<ext/pb_ds/assoc_container.hpp>
  4. #include<ext/pb_ds/tree_policy.hpp>
  5. using namespace std;
  6. using namespace __gnu_pbds;
  7. template<class T> using ordered_set =tree<T, null_type, less_equal<T>, rb_tree_tag,tree_order_statistics_node_update> ;
  8. template <typename T = int>ostream &operator<<(ostream &out, const vector<T> &v){for (const T &x : v)    out << x << ' ';return out;}
  9. template <typename T = int>istream &operator>>(istream &in, vector<T> &v){for (auto &x : v) in >> x;return in;}
  10. using namespace __gnu_pbds;
  11. #define getline(s) getline(cin >> ws ,s)
  12. #define ll long long
  13. #define sz(s)   (int)(s.size())
  14. #define cin(vec, n);  for (int i = 0; i < n and cin >> vec[i]; i++);
  15. const int M = 2 * 1e5 + 5;
  16. #define HABIBA ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  17. #define PI 3.14159
  18. #define ull unsigned long long
  19. #define all(s) s.begin(), s.end()
  20. #define Mod  1'000'000'007
  21. #define to_binary(bin) stoll(bin, nullptr, 10)
  22. #define ceill(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  23. #define cin(v) for(auto &i: v)  cin>>i
  24. #define cout(v) for(auto &i: v) cout<<i<<" ";
  25. using namespace std;
  26. #define Num_of_Digits(n) ((int)log10(n) + 1)
  27. // freopen("equal.in", "r", stdin);
  28. /* #ifndef ONLINE_JUDGE
  29.         freopen("machines.in", "r", stdin), freopen("standard output", "w", stdout);
  30.  #endif*/
  31. /*void set_file(string& file_name){
  32.     freopen((file_name + ".in").c_str(), "r", stdin);
  33.     freopen((file_name + ".out").c_str(), "w", stdout);
  34. }*/
  35. vector < ll > ans;
  36. vector < vector < ll > > test;
  37. void solve(ll index , ll n){
  38.      if(index == n){
  39.          test.push_back(ans);
  40. //         cout << ans << "\n";
  41.          return;
  42.      }
  43.  
  44.      ans.push_back(0);
  45.      solve(index + 1 , n);
  46.      ans.pop_back();
  47.  
  48.      ans.push_back(1);
  49.      solve(index + 1 , n);
  50.      ans.pop_back();
  51.  
  52.      return;
  53.  
  54.  
  55. }
  56.  
  57.  
  58. int main() {
  59. #ifndef ONLINE_JUDGE
  60.     freopen("input.txt", "r", stdin),
  61.             freopen("output.txt", "w", stdout);
  62. #endif
  63.     HABIBA
  64.     ll t;                                cin >> t;
  65.     while(t--){
  66.         ll n;                            cin >> n;
  67.         solve(0 , n);
  68.         sort(all(test));
  69.         for(auto & i : test){
  70.            // for(auto j : i) cout << j << "\n";
  71.            cout << i << "\n";
  72.         }
  73.       ans.clear() , test.clear();
  74.     }
  75.  
  76.     return 0;
  77. }
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92. //vector < vector < int > > v(n , vector < int > (m));
  93. //for(auto & I : v){
  94. //for(auto & x : I){
  95. //cin >> x ;
  96. // 2d vector and cin
  97. //}
  98. //}
  99. //             mst2.erase(prev(mst2.end()));
  100. //bool operator < (const Indx &other) const{
  101. //
  102. //}
  103.  
  104.  
  105. // find by order --> iterator   // *find by order --> value
  106. // order of key --> index + 1
  107.  
  108. //cout << __builtin_popcount(n);
  109.  
  110. //auto pr = std::max_element(map.begin(), map.end(), [](const auto &x, const auto &y) {
  111. //    return x.second < y.second;
  112. //std::cout << std::fixed << std::setprecision(2) << d;
Advertisement
Add Comment
Please, Sign In to add comment