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;
typedef long long LL;
int ComputePower (LL k) {
int l = 0;
while ((1LL<<l) <= k / 2)
++ l;
return l;
}
std::vector<int> construct_permutation(long long k)
{
int L = ComputePower(k);
k -= ((1LL<<L));
vector <int> ans;
vector <int> V;
int value = -1;
for (int i = 0; i < L; ++ i ) {
++ value;
if ((k&(1LL<<i))) {
V.push_back(value);
++ value;
}
ans.push_back(value);
}
for (int i = V.size()-1; i >= 0; -- i )
ans.push_back(V[i]);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |