# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1165478 | baldwin_huang | Permutation (APIO22_perm) | C++20 | 0 ms | 320 KiB |
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> construct_permutation(long long k) {
int greatest_power_of_two;
for (int i = 63; i >= 0; i--) {
if (k & (1 << i)) {
greatest_power_of_two = i;
break;
}
}
vector<int> pre_ans;
long long diff = k - (1 << greatest_power_of_two);
int counter = greatest_power_of_two;
for (int i = greatest_power_of_two - 1; i >= 0; i--) {
pre_ans.push_back(i);
if (diff & (1 << i)) {
pre_ans.push_back(counter);
counter++;
}
}
vector<int> ans;
for (int i = pre_ans.size() - 1; i >= 0; i--) {
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |