Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- #define el endl
- #define umi unordered_map<int, int>
- #define umll unordered_map<ll, ll>
- #define all(vect) vect.begin(), vect.end()
- #define reset(A) memset(A, true, sizeof(A))
- #define approx(n) fixed << setprecision(n)
- #define pb push_back
- const int mod = 1e9 + 7;
- using namespace std;
- int n;
- int a[1001], c[1001];
- bool check[1001];
- void print()
- {
- for(int i = 1; i <= n; i++)
- {
- cout << c[a[i]] << " ";
- }
- cout << el;
- }
- void back(int i)
- {
- for(int j = 1; j <= n; j++)
- {
- if(check[j])
- {
- a[i] = j;
- check[j] = false;
- if(i == n)
- {
- print();
- }
- else
- back(i + 1);
- check[j] = true;
- }
- }
- }
- void solve()
- {
- reset(check);
- cin >> n;
- for(int i = 1; i <= n; i++)
- {
- cin >> c[i];
- }
- sort(c + 1, c + n + 1);
- back(1);
- }
- int main()
- {
- int t = 1;
- // cin >> t;
- // cin.ignore();
- while(t--)
- {
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement