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;
#define ll long long
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)
vector<int> construct_permutation(ll k){
vector<int>Ans;
bitset<64>a=k;
int group=0;
for(int i=0;i<=64;i++){
if(a[i]){
group++;
for(int j=0;j<i;j++)
Ans.push_back(j);
}
}
int n=Ans.size(), cur=0;
for(int i=n-1;i>=0;i--){
if(!Ans[i]){
int ind=i;
while(true){
int now=Ans[ind];
Ans[ind]=cur++;
if(ind<n-1 && now<Ans[ind+1])
ind++;
else
break;
}
}
}
group--;
vector<int>G;
while(group--)
G.push_back(cur++);
for(int i=0;i<n;i++)
G.push_back(Ans[i]);
Ans=G;
return Ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |