#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
template <class T> vector<int> compress(vector<T> a) {
int N = a.size();
vector<T> b(a.begin(), a.end());
sort(b.begin(), b.end());
vector<int> ans;
for (T i : a) ans.emplace_back(lower_bound(b.begin(), b.end(), i) - b.begin());
return ans;
}
vector<int> construct_permutation(long long k) {
int o = __lg(k), cnt = __builtin_popcountll(k);
vector<double> ans;
for (int i = 1; i <= o; i++) ans.emplace_back(i);
for (int64_t i = o-1; i >= 0; i--)
if (k>>i&1LL) ans.emplace_back(((i == 0 ? 0 : ans[i-1]) + ans[i]) * 0.5);
return compress(ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |