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)
{
vector<int> s;
int sum = 0;
k--;
for(int f=18;f>=2;f--){
if((1LL<<f)-1<=k){
s.push_back(f);
k-=((1<<f)-1);
sum+=f;
}
}
sum+=k;
for(int i=0;i<k;i++) s.push_back(1);
vector<int> ans;
for(auto l : s){
for(int i=sum-l+1;i<=sum;i++) ans.push_back(i-1);
sum-=l;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |