# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
745385 | Patrick | Permutation (APIO22_perm) | C++17 | 2 ms | 340 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;
using ll = long long;
std::vector<int> construct_permutation(long long k) {
ll v = 1;
ll a = 0;
while (v * 2 <= k) {
v *= 2;
a++;
}
k -= v;
vector<int> inc(a);
while (k > 0) {
ll s = 0;
while ((1LL << (s + 1)) <= k) {
s++;
}
inc[s] = a++;
k -= (1LL << s);
}
vector<int> ans;
for (int i = 0; i < inc.size(); i++) {
if (inc[i] != 0) ans.push_back(inc[i]);
ans.push_back(i);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |