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;
using ll = long long;
std::vector<int> construct_permutation(long long k)
{
int m = 64 - __builtin_clzll(k);
vector<int> zero(m + 1);
int pad = 0;
for (int j = 0; j <= m; j++) {
if (k & (1ll << j)) {
zero[m - j - 1] = ++pad;
}
}
vector<int> ans;
for (int i = 1; i < m; i++) {
ans.push_back(i + pad - 2);
if (zero[i]) ans.push_back(zero[i] - 1);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |