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;
vector<int> construct_permutation(long long k)
{
long long beg = __lg(k);
vector<int> ans;
for(int i = 0; i < beg; i++)
ans.push_back(i);
long long rem = k - (1LL << beg);
for(long long i = beg - 1; i >= 0; i--)
{
if(rem & (1 << i))
{
rem -= (1 << i);
ans.insert(ans.begin() + i, beg++);
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |