# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
820943 | Hanksburger | Permutation (APIO22_perm) | C++17 | 11 ms | 1108 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;
vector<int> vec, ans;
vector<int> construct_permutation(long long k)
{
vec.clear();
ans.clear();
for (long long i=59; i>=1; i--)
{
while (k>(1LL<<i)-1)
{
k-=(1LL<<i)-1;
vec.push_back(i);
}
}
long long sum=0;
for (long long i=0; i<vec.size(); i++)
{
for (long long j=sum+vec[i]-1; j>=sum; j--)
ans.push_back(j);
sum+=vec[i];
}
reverse(ans.begin(), ans.end());
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |