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 lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define pb push_back
#define pf push_front
lli cont;
deque<lli> perm;
void arma(lli num) {
lli mitad = num/2;
if (mitad == 0) return;
arma(mitad);
perm.pb(cont++);
if (num&1) perm.pf(cont++);
}
std::vector<int> construct_permutation(long long k)
{
cont = 0;
arma(k);
lli act;
vector<int> res;
res.resize(cont);
cont = 0;
while (!perm.empty()) {
act = perm.front();
perm.pop_front();
res[cont++] = act;
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |