# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1165482 | baldwin_huang | Permutation (APIO22_perm) | C++20 | 1 ms | 328 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 & (1LL << i)) {
greatest_power_of_two = i;
// cout << (1 << 63) << '\n';
break;
}
}
// cout << "Greatest: " << greatest_power_of_two << '\n';
vector<int> pre_ans;
long long diff = k - (1LL << 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 & (1LL << i)) {
pre_ans.push_back(counter);
counter++;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |