# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
737668 | 2023-05-07T13:50:12 Z | tegid | Mars (APIO22_mars) | C++17 | 0 ms | 0 KB |
#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{ vector<int> v=construct_permutation(k-1); for(int i=0;i<(int)v.size();i++)v[i]++; v.pb(0); return v; } } }