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;
vector<int> construct_permutation(long long k) {
int last_digit = 63 - __builtin_clzll(k);
int extras = __builtin_popcountll(k);
vector<int> ans;
int lo = extras - 2;
int hi = extras - 1;
for (int b = last_digit - 1; b >= 0; b--) {
ans.push_back(hi++);
if ((k >> b) & 1) ans.push_back(lo--);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |