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 <stdio.h>
#include <algorithm>
std::vector<int> construct_permutation(long long k)
{
std::vector<int> v;
int msb = 63 - __builtin_clzll(k);
for (int i = 1; i <= msb; ++i) v.push_back(i*2);
k &= ~(1ll << msb);
for (int i = msb - 1; i >= 0; --i)
{
if (k & (1ll << i))
{
v.push_back(i*2+1);
}
}
auto w = v;
std::sort(w.begin(), w.end());
for (int &x : v) x = std::lower_bound(w.begin(), w.end(), x) - w.begin();
//for (int x : v) printf("%d ", x);
return v;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |