# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1118734 | Username_taken12 | 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>
using namespace std;
vector<int> construct_permuation(long long k) {
int cnt = popcount((unsigned long long) k);
int size =0;
long long t=k;
while(t>0){
size++;
t/=2;
}
int len = size+cnt-1;
int h=len;
int a =1;
vector<int> out;
while(k>1){
if(k%2==1)
out.push_back(h--);
out.push_back(a++);
k/=2;
}
return out;
}