# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
573143 | dqhungdl | Permutation (APIO22_perm) | C++17 | 2 ms | 352 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;
int getBit(long long x, int k) {
return (x >> k) & 1LL;
}
vector<int> construct_permutation(long long k) {
if (!k)
return {};
int last = 0;
for (int i = 0; i <= 60; i++)
if (getBit(k, i))
last = i;
vector<int> rs(last);
iota(rs.begin(), rs.end(), 0);
for (int i = last - 1; i >= 0; i--)
if (getBit(k, i)) {
for (int j = i; j < rs.size(); j++)
rs[j]++;
rs.push_back(i);
}
// for (int x: rs)
// cout << x << ' ';
// cout << '\n';
return rs;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |