Author: loop3r
Date: 20260224
tag: 枚举
link: https://www.luogu.com.cn/problem/P1088问题描述
分析
使用 next_permutation 计算当前排序后第
参考代码
cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, a[10010];
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> a[i];
while (m--) {
next_permutation(a + 1, a + 1 + n);
}
for (int i = 1; i <= n; i++) cout << a[i] << " ";
return 0;
}