# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
976006 | Orifkhon | Permutation (APIO22_perm) | C++17 | 0 ms | 0 KiB |
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<bits/stdc++.h>
#include "perm.h"
using namespace std;
#ifdef LOCAL
#include "debug.cpp"
#else
#define debug(...)
#endif
#define ll long long
vector<int> construct_permutation(long long k) {
ll size = 63 - __builtinll_clz(k);
vector<int> perm(size);
for(int i = 0; i < size; i++){
perm[i] = i;
}
k-=(1ll << size);
ll insert = size;
while(k > 0){
ll ind = 63 - __builtinll_clz(k);
k-=(1ll << ind);
perm.insert(perm.begin() + ind, insert);
insert++;
}
debug(perm);
return perm;
}