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 "perm.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> construct_permutation(long long k) {
vector<int> ans;
int h = __lg(k);
for (int i = 0, j = 0; i < h; i++) {
while (j < h && k >> j & 1) {
j++;
}
ans.push_back(j++);
}
for (int i = h - 1; i >= 0; i--) {
if (k >> i & 1) {
ans.push_back(i);
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |