Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <vector>
- #include <string>
- #include <queue>
- #include <map>
- #include <set>
- #include <string>
- #include <algorithm>
- #include <cmath>
- #include <unordered_map>
- #include <unordered_set>
- using namespace std;
- #define ll long long
- #define nl endl
- #define cy cout << "YES\n"
- #define cn cout << "NO\n"
- #define sz(s) s.size()
- #define all(v) v.begin(), v.end()
- #define cin(vec) for (int i = 0; i < n && cin >> vec[i]; i++)
- #define cout(vec) for (int i = 0; i < n && cout << vec[i] << " "; i++)
- void sherry()
- {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- int n;
- vector<int> v, curr;
- vector<vector<int>> vec;
- bool valid()
- {
- for (int i = 1; i < sz(curr); i++)
- {
- if (curr[i] <= curr[i - 1])
- return false;
- }
- return true;
- }
- void rec(int i)
- {
- if (i == sz(v))
- {
- if (!curr.empty())
- {
- if (valid())
- vec.push_back(curr);
- }
- return;
- }
- curr.push_back(v[i]);
- rec(i + 1);
- curr.pop_back();
- rec(i + 1);
- }
- void solve()
- {
- cin >> n;
- v.assign(n, 0);
- cin(v);
- rec(0);
- sort(all(vec));
- for (int i = 0; i < sz(vec); i++)
- {
- for (int j = 0; j < sz(vec[i]); j++)
- {
- cout << vec[i][j] << " ";
- }
- cout << endl;
- }
- }
- int main()
- {
- sherry();
- ll t = 1;
- // cin >> t;
- while (t--)
- {
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement