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;
int cur;
vector<int> ans;
void construct(int k) {
if (k == 1) {
return;
}
if (k % 2 == 1) {
construct(k - 1);
ans.insert(ans.begin(), -1);
}
else {
construct(k / 2);
ans.push_back(cur);
cur ++;
}
return;
}
vector<int> construct_permutation(long long k)
{
cur = 0;
ans.clear();
construct(k);
for (int i = ans.size() - 1; i >= 0; i --) {
if (ans[i] == (-1)) {
ans[i] = cur;
cur ++;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |