#include "perm.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long INF = 1e17;
typedef long long ll;
const ll MOD = 998244353;
#define F first
#define pb push_back
#define S second
#define P pair
#define V vector
#define all(v) v.begin(), v.end()
std::vector<int> construct_permutation(long long k)
{
k--;
V<int>vp;
int c=0;
for (int i=60;i>=0;i--) {
if (((1LL<<i)&k)!=0) {
vp.pb(i);
c++;
}
}
vp.pb(c);
int s=0;
for (auto u:vp) {
s+=u;
}
s--;
V<int>p;
for (int i=0;i<(int)vp.size();i++) {
int u=vp[i];
s=s-u;
if (i==(int)vp.size()-1) {
for (int j=s+u;j>s;j--) {
p.pb(j);
}
}
else {
for (int j=s+1;j<=s+u;j++) {
p.pb(j);
}
}
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |