#include <bits/stdc++.h>
using namespace std;
int n, k, a[10005], ans[10005], sum;
bool vis[100005];
void dfs(int x){
if(x > n){
sum++;
if(sum == k + 1){
for(int i = 1; i < x; i++) cout << ans[i] << " ";
exit(0);
}
return ;
}
for(int i = 1; i <= n; i++){
if(!vis[i]){
ans[x] = a[i];
vis[i] = 1;
dfs(x + 1);
vis[i] = 0;
}
}
}
signed main(){
ios_base::sync_with_stdio(false);
cout.tie(0), cin.tie(0);
cin >> n >> k;
for(int i = 1; i <= n; i++) cin >> a[i];
dfs(1);
return 0;
}
此代码只有 30 分,求各位大佬帮忙看看,悬关!!