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;
typedef long long ll;
#define pb emplace_back
vector<int> construct_permutation(ll k){
if(k<=4){
if(k==2)return {0};
if(k==3)return {1, 0};
if(k==4)return {0, 1};
return {}; // should not happen
}else{
if(k%2==0){
vector<int> v=construct_permutation(k/2);
vector<int> ans;
ans.pb(0);
for(int i=0;i<(int)v.size();i++)ans.pb(v[i]+1);
return ans;
}else{
vector<int> v=construct_permutation(k-1);
for(int i=0;i<(int)v.size();i++)v[i]++;
v.pb(0);
return v;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |