이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
n=Ans.size();
for(int i=0;i<n;i++){
cout<<Ans[i]<<' ';
}
return Ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |