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
- }
- ll nCr(ll n, ll r)
- {
- if (n < r)
- return 0;
- ll res = 1;
- for (ll i = 1; i <= r; i++)
- {
- res *= n--;
- res /= i;
- }
- return res;
- }
- int n;
- vector<int> v;
- multiset<vector<int>> vec;
- vector<int> curr;
- void printVector(vector<int> myVector)
- {
- if (myVector.size() > 0)
- {
- for (int i = 0; i < myVector.size(); i++)
- {
- cout << myVector[i] << " ";
- }
- cout << "\n";
- }
- }
- void print(multiset<vector<int>> &multisetOfVectors)
- {
- }
- void rec(int i)
- {
- if (i == n)
- {
- vector<int> s = curr;
- sort(s.begin(), s.end());
- if (s == curr)
- vec.insert(s);
- return;
- }
- curr.push_back(v[i]);
- rec(i + 1);
- curr.pop_back();
- rec(i + 1);
- }
- void solve()
- {
- cin >> n;
- v = vector<int>(n);
- cin(v);
- rec(0);
- for (auto it = vec.begin(); it != vec.end(); it++)
- {
- printVector(*it);
- }}
- int main()
- {
- sherry();
- ll t = 1;
- // cin >> t;
- while (t--)
- {
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement