# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
984750 | Uultan12 | Permutation (APIO22_perm) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <vector>
#include <algorithm>
std::vector<int> construct_permutation(int64_t k) {
int n = 1;
while ((n * (n + 1)) / 2 < k) {
++n;
}
std::vector<int> permutation(n);
for (int i = 0; i < k; ++i) {
permutation[i] = i;
}
// Fill the remaining elements with values not used in the increasing subsequence
int next_value = k;
for (int i = k; i < n; ++i) {
permutation[i] = next_value++;
}
return permutation;
}