Cod sursa(job #3212464)

Utilizator QwertyDvorakQwerty Dvorak QwertyDvorak Data 11 martie 2024 19:32:26
Problema Generare de permutari Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.52 kb
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define dbg(x) cout << #x << ": " << x << "\n";
#define sz(x) ((int)x.size())

using ll = long long;

const string fn = "permutari";
ifstream fin(fn + ".in");
ofstream fout(fn + ".out");

int n;
bitset<2000005> v;

int main()
{
    fin >> n;
    vector<int> v;
    for (int i = 1; i <= n; ++i)
        v.pb(i);
    do
    {
        for (auto i : v)
            fout << i << ' ';
        fout << '\n';
    } while (next_permutation(v.begin(), v.end()));

    return 0;
}