# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
699132 | dxz05 | Permutation (APIO22_perm) | C++17 | 12 ms | 1320 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;
vector<int> construct_permutation(long long k){
int lg = 63 - __builtin_clzll(k);
k--;
vector<int> blocks;
int x = 61;
while (k > 0){
if (k >= (1ll << x) - 1){
k -= (1ll << x) - 1;
blocks.push_back(x);
x++;
}
x--;
}
vector<int> res;
for (int sz : blocks){
int val = res.size() + sz - 1;
for (int i = 0; i < sz; i++){
res.push_back(val--);
}
}
reverse(res.begin(), res.end());
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |