1 条题解
-
0
【本题解由站长编写】
NOIP2004 火星人:对手指排列连续执行 M 次 next_permutation 即可(M≤100、N≤10000,总代价 10⁶)。
代码(C++17)
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> a(n); for (auto &x : a) cin >> x; for (int i = 0; i < m; i++) next_permutation(a.begin(), a.end()); for (int i = 0; i < n; i++) cout << a[i] << (i + 1 == n ? '\n' : ' '); return 0; }
- 1
信息
- ID
- 4289
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 5
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者