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;
vector<int> construct_permutation(long long k) {
vector<int> a;
int c = 0, t = 0;
for (int i = __lg(k) - 1; ~i; i--) {
a.push_back(t++);
if (k >> i & 1) {
if (i > 0 && (k >> (i - 1) & 1) && c > 1)
a.push_back(t++), a.insert(a.begin() + 2, t++), i--;
else
a.insert(a.begin(), t++), c++;
}
}
return a;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |