Cod sursa(job #2851580)

Utilizator SlavicGGuzun Veaceslav SlavicG Data 18 februarie 2022 20:33:43
Problema Generare de permutari Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.78 kb
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long
 
#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()
 
#define            pb                push_back
#define          sz(a)               (int)a.size()

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    iota(all(a), 1);
    do{
        for(auto x: a) cout << x << " ";
        cout << "\n";
    }while(next_permutation(all(a)));
} 
 
int32_t main() {
    freopen("permutari.in", "r", stdin);
    freopen("permutari.out", "w", stdout);
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}