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"
std::vector<int> construct_permutation(long long k)
{
std::vector<int> a;
long long l = 0, r = 0, dd = 0;
auto work = [&](auto self, long long x) -> void {
if (x & 1) {
a.push_back(--l);
dd = l;
self(self, x - 1);
}
else {
a.push_back(++r);
self(self, x >> 1);
}
};
work(work, k);
for (auto& x : a)
x -= (dd - 1);
return a;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |