# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1068848 | kilikuma | Permutation (APIO22_perm) | C++17 | 0 ms | 0 KiB |
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;
#define int long long
vector<int> construct_permutation(int k)
{
vector<int> ans;
k --;
vector<int> 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;
}