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"
using namespace std;
std::vector<int> construct_permutation(long long k)
{
long long cur = 1;
vector<int> res;
for (int i = 0;; i++)
{
int exp = 0;
long long power2 = 1;
while (cur + power2 * 2LL <= k && (exp + 1) <= i)
{
power2 *= 2;
exp++;
}
cur += power2;
res.insert(res.begin() + exp, i);
if (cur == k)
break;
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |