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<iostream>
#include<vector>
#include<algorithm>
#include "perm.h"
using namespace std;
std::vector<int> construct_permutation(long long k)
{
vector<int> sol;
long long nrs=1;
int cnt=0;
for(int i=1;i<60;i++)
{
if(((1LL<<i)&k))
{
for(int j=cnt+i-1;j>=cnt;j--)
sol.push_back(j);
cnt += i;
nrs += (1LL<<i)-1;
}
}
for(int j=1;j<=k-nrs;j++)
{
sol.push_back(cnt);
cnt++;
}
reverse(sol.begin(),sol.end());
return sol;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |