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> ans;
k --;
vector<long long> puis(61, 1);
for (int i = 1; i < 61; i ++) {
puis[i] = puis[i - 1] * 2;
}
int cur = -1;
for (int i = 60; i >= 1; i --) {
while (puis[i] - 1 <= k) {
for (int j = cur + i; j >= cur + 1; j --) {
ans.push_back(j);
}
cur += i;
k -= (puis[i] - 1);
}
}
reverse(ans.begin(), ans.end());
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |