You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
328 B

#include <bits/stdc++.h>
using namespace std;
const int N = 10010;
int a[N];
int main() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++)cin >> a[i];
while (m--)
next_permutation(a + 1, a + n + 1);
for (int i = 1; i <= n; i++)
printf("%d ", a[i]);
return 0;
}