# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
744378 | merlynn | 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;
vector<long long> construct_permutation(long long k) {
string bn="";
while(k)
{
bn+=k%2+'0';
k/=2;
}
reverse(bn.begin(),bn.end());
vector<long long> ret;
int cur=0;
for(long long i=1;i<bn.size();i++)
{
ret.push_back(cur++);
if(bn[i]=='1')
ret.insert(ret.begin(),cur++);
}
return ret;
}