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 {};
}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 if(k%3==0){
vector<int> v=construct_permutation(k/3);
vector<int> ans;
ans.pb(1);
ans.pb(0);
for(int i=0;i<(int)v.size();i++)ans.pb(v[i]+2);
return ans;
}else if (k%5==0){
vector<int> v=construct_permutation(k/5);
vector<int> ans;
ans.pb(1);
ans.pb(2);
ans.pb(0);
for(int i=0;i<(int)v.size();i++)ans.pb(v[i]+3);
return ans;
}else if (k%7==0){
vector<int> v=construct_permutation(k/7);
vector<int> ans;
ans.pb(2);
ans.pb(3);
ans.pb(0);
ans.pb(1);
for(int i=0;i<(int)v.size();i++)ans.pb(v[i]+4);
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... |