# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
584200 | jairRS | 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"
using namespace std;
std::vector<int> construct_permutation(long long k)
{
long long cur = 1, power2 = 1;
vector<int> res;
int exp = 0;
while (cur + power2 <= k)
{
cur += power2;
res.push_back(res.size());
power2 *= 2;
exp++;
}
while (cur < k)
{
while (cur + power2 > k)
{
power2 /= 2;
exp--;
}
cur += power2;
res.insert(res.begin() + exp, res.size());
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |