Untitled

 avatar
unknown
plain_text
13 days ago
1.2 kB
4
Indexable
#include <bits/stdc++.h>
using namespace std ;
#define For(n) for(long long i = 0; i < n; i++)
#define endl '\n'
#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//***********************Nah I would win*************************/
int n,x;
vector<vector<int>> v;
vector<int> nums;
void rec(vector<int> sub, int idx){
    if(idx == nums.size()){
        if (!sub.empty()) v.push_back(sub);
        return;
    }   
    // cout<< s << ' '<<in[idx] << endl;
    rec(sub,idx+1); 
    sub.push_back(nums[idx]);
    rec(sub , idx+1);       
} 
bool is_sorted(vector<int>& v){
    vector<int> tmp = v;
    sort(tmp.begin(),tmp.end());
    for(int i = 0; i < v.size(); i++)
        if(v[i] != tmp[i])return false;
    return true;     
}  
void Gojo(){
    cin>>n;
    For(n){
        cin>>x;
        nums.push_back(x);
    }
    vector<int> a;
    rec(a,0);
    sort(v.begin(),v.end());
    // int ans = 0;
    for(vector<int> it:v){
        if(! is_sorted(it))continue;
        For(it.size())cout << it[i] <<' ';
        cout << endl;          
    }
    // cout << ans;
 }
signed main()
{
    fast   
    int Tt =1;
    // cin>>Tt;
    while (Tt--){
        Gojo();
        // cout << endl;
    }    
}
Leave a Comment