Cod sursa(job #2288929)

Utilizator gabiluciuLuciu Gabriel gabiluciu Data 24 noiembrie 2018 09:41:55
Problema Generare de permutari Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.27 kb
#include <bits/stdc++.h>
#define nl '\n'
using namespace std;
int dreptunghiMaxSubHistograma(int a[],int nrElem){
    stack<int> p;
    int arie,ariemax=0,i,tmp;
    for(int i=0;i<nrElem;i){
        if(p.empty() || a[i]>a[p.top()])
            p.push(i++);
        else{
            tmp = p.top();
            p.pop();
            if(p.empty())
                arie = a[tmp] * i;
            else
                arie = a[tmp] * (i-p.top()-1);
            if(arie>ariemax)
                ariemax = arie;
        }
    }
    while(!p.empty()){
        tmp = p.top();
        p.pop();
        if(p.empty())
            arie = a[tmp] * nrElem;
        else
            arie = a[tmp]*(nrElem-p.top()-1);
        if(arie>ariemax)
            ariemax = arie;
    }
    return ariemax;
}
bool a[1000][1000];

inline void gen(int n){

}


int main (){
    freopen("permutari.in","r",stdin);
    freopen("permutari.out","w",stdout);
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    vector<int> v;
    int n;
    cin >> n;

    for(int i=1;i<=n;++i){
        v.push_back(i);
    }
    do{
        for_each(v.begin(),v.end(),[](int a){cout << a << ' ';});
        cout  << nl;
    }while(next_permutation(v.begin(),v.end()));

    return 0;
}