#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, a, b) for (int i = a; i <= b; ++i)
std::vector<int> construct_permutation(long long k)
{
vector<int> ans;
vector<ll> cc;
ll sz = 0, i = 60, n = k;
while (n > 1) {
if (n - (1LL<<i) + 1 >= 1) {
cc.push_back(i);
n -= (1LL<<i)-1;
sz += (i);
}
else {
i--;
}
}
ll tmp = sz;
rep(j,0,cc.size()-1) {
int k = cc[j];
rep(h, tmp-k+1, tmp) ans.push_back(h-1);
tmp -= cc[j];
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |