#include<iostream>#include<cstdio>#include<algorithm>#include<cmath>usingnamespace std;int n, m;int t[10010];intmain(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);// freopen("in.txt", "r", stdin);// freopen("out.txt", "w", stdout);
cin >> n >> m;for(int i =0; i < n; i++) cin >> t[i];while(m--)next_permutation(t, t+n);
cout << t[0];for(int i =1; i < n; i++) cout <<" "<< t[i];return0;}
Two
#include<iostream>#include<cstdio>#include<algorithm>#include<cmath>#include<cstring>#include<string>#include<set>#include<iterator>#include<algorithm>#include<vector>usingnamespace std;int n, m;int t[10010], vis[10010];voidencoder(){memset(vis,0,sizeof(vis));for(int i =1; i <= n; i++){int cur = t[i];for(int j =1; j <= t[i]; j++) cur -= vis[j];
vis[t[i]]=1;
t[i]= cur-1;}}voidadd(){
t[n]+= m;// never mind about t[0], it is exactly no use according to the question// in other word, the aliens' fingers will not increasefor(int i = n; i >0; i--){
t[i-1]+= t[i]/(n-i+1);
t[i]= t[i]%(n-i+1);}}voiddecoder(){memset(vis,0,sizeof(vis));for(int i =1; i <= n; i++){for(int j =0; j <= t[i]; j++)if(vis[j]) t[i]++;
vis[t[i]]=1;
t[i]++;}}intmain(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);// freopen("in.txt", "r", stdin);// freopen("out.txt", "w", stdout);
cin >> n >> m;for(int i =1; i <= n; i++) cin >> t[i];encoder();add();decoder();
cout << t[1];for(int i =2; i <= n; i++) cout <<" "<< t[i];return0;}