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 "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
vector<int> construct_permutation(long long k) {
if (k == 1) return {};
if (k == 2) return {0};
if (k == 3) return {1, 0};
auto p = construct_permutation(k / 4);
int n = p.size();
if (k % 4 == 0) {
p.push_back(n);
p.push_back(n + 1);
} else if (k % 4 == 1) {
p.push_back(n);
p.push_back(n + 1);
p.push_back(-1);
} else if (k % 4 == 2) {
p.push_back(n);
p.push_back(-1);
p.push_back(n + 1);
} else {
p.insert(p.begin(), -1);
p.insert(p.begin(), n);
p.push_back(n + 1);
}
auto q = p;
sort(q.begin(), q.end());
for (int &v : p)
v = lower_bound(q.begin(), q.end(), v) - q.begin();
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |