Cod sursa(job #2858077)

Utilizator MR0L3eXMaracine Constantin Razvan MR0L3eX Data 26 februarie 2022 22:09:33
Problema Generare de permutari Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.57 kb
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"

using namespace std;

using ld = long double;
using ll = long long;
using ull = unsigned long long;

#if defined(ONPC)
#include "bits/debug.h"
#endif

ifstream fin("permutari.in");
ofstream fout("permutari.out");


int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    fin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) v[i] = i;
    do {
        for (int &x : v) cout << x + 1 << ' ';
        fout << "\n";
    } while(next_permutation(v.begin(), v.end()));
}