#include "perm.h"
#include <bits/stdc++.h>
#define ll long long
#define se second
#define fi first
#define pb push_back
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
using namespace std;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> ipii;
const int MAXN = 8e5+15;
const int SQRT = 560;
const int INF = 1e9+10;
const int MOD = 998244353;
const int LOG = 20;
std::vector<int> construct_permutation(long long k){
if(k <= 1) return {};
if(k == 2) return {0};
if(k == 3) return {1, 0};
if(k == 5) return {2, 0, 1};
if(k == 7) return {3, 1, 0, 2};
vector<int> ANS;
if(k%3 == 0){
vector<int> ANS = construct_permutation(k/3);
int siz = ANS.size();
ANS.pb(siz+1);
ANS.pb(siz);
return ANS;
}
if(k%5 == 0){
vector<int> ANS = construct_permutation(k/5);
int siz = ANS.size();
ANS.pb(siz+2);
ANS.pb(siz);
ANS.pb(siz+1);
return ANS;
}
if(k%7 == 0){
vector<int> ANS = construct_permutation(k/7);
int siz = ANS.size();
ANS.pb(siz+3);
ANS.pb(siz+1);
ANS.pb(siz);
ANS.pb(siz+2);
return ANS;
}
ANS = construct_permutation(k/2);
ANS.pb(ANS.size());
if(k&1) ANS.emplace(ANS.begin(), ANS.size());
return ANS;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |