Cod sursa(job #2726200)

Utilizator avtobusAvtobus avtobus Data 20 martie 2021 14:44:54
Problema Generare de permutari Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.62 kb
#include <algorithm>
#include <stdio.h>
#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
// const int INF = 0x3f3f3f3f;

ifstream fin {"permutari.in"};
ofstream fout {"permutari.out"};

int main(void) {
  // freopen("permutari.in", "r", stdin);
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  int N;
  fin >> N;
  vi v(N, 0);
  iota(v.begin(), v.end(), 1);
  do {
    for(auto &x: v) { fout << x << ' '; }
    fout << '\n';
  } while(next_permutation(v.begin(), v.end()));

  return 0;
}