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 "perm.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
std::vector<int> construct_permutation(long long k)
{
k--;
int n = 0;
vector<int> bits;
for(ll i = 0 ; i < 60 ; i++)
{
if((1ll<<i) & k)
{
bits.push_back(i);
n+=i + 1;
}
}
n--;
vector<int> perm;
for(auto i : bits)
{
for(int j = n - i + 1 ; j <= n ; j++)
{
perm.push_back(j);
}
n-=i;
}
while(n >= 0)
{
perm.push_back(n);
n--;
}
return perm;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |