火星人
调库next_permutation() -> 返回全排列的下一个字典序最小的序列
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#define N 10010
using namespace std;
int n,m;
int q[N];
int main()
{
scanf("%d%d",&n,&m);
for(int i = 0;i < n;i ++) scanf("%d",&q[i]);
while(m --) next_permutation(q,q+n);
for(int i = 0;i < n;i ++) printf("%d ",q[i]);
return 0;
}