#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ari2 = array<int, 2>;
using ari3 = array<int, 3>;
using arl2 = array<ll, 2>;
using arl3 = array<ll, 3>;
template <class T> using vt = vector<T>;
#define all(x) begin(x), end(x)
#define size(x) (int((x).size()))
#define REP(a,b,c,d) for(int a=(b);(d)>0?a<=(c):a>=(c);a+=(d))
#define FOR(a,b,c) REP(a,b,c,1)
#define ROF(a,b,c) REP(a,b,c,-1)
vt<int> construct_permutation(ll k) {
k--;
int x = 0;
for (; (1ll << x + 1) - 2 < k; x++);
k -= (1ll << x) - 1;
vt<int> ret(x);
iota(all(ret), 0);
ROF(i, x-1, 0)
if (k >> i & 1) {
FOR(j, i, size(ret)-1)
ret[j]++;
ret.push_back(ret[i] - 1);
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |