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)
{
k--;
vector<int>res;
long long sz=0;
long long fk=k;
for(long long j=62;j>=1;j--){
while(k>=((1ll<<j)-1)){
sz+=j;
// cout<<k<<endl;
k-=((1ll)<<j)-1;
}
}
res.resize(sz);
long long now=sz;
k=fk;
long long noww=0;
for(long long j=62;j>=1;j--){
while(k>=((1ll<<j)-1)){
long long fake=now-j;
for(long long h=0;h<j;h++,fake++,noww++){
res[noww]=fake;
}
now-=j;
// cout<<k<<endl;
k-=(1ll<<j)-1;
}
}
//for(auto x:res){
// cout<<x<<" ";
//}
//cout<<"\n";
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |