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 <bits/stdc++.h>
#include "perm.h"
using namespace std;
using ll = long long;
std::vector<int> construct_permutation(long long k) {
vector<int> ops, perm;
while (k > 1) {
if (k & 1) {
k--;
ops.push_back(1);
} else {
k /= 2;
ops.push_back(0);
}
}
reverse(ops.begin(), ops.end());
int cur = 0;
for (auto& x : ops) {
if (x == 0) {
perm.push_back(cur++);
} else perm.insert(perm.begin(), cur++);
}
return perm;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |