# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1041351 | MarwenElarbi | Permutation (APIO22_perm) | C++17 | 1 ms | 348 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 <bits/stdc++.h>
#include "perm.h"
using namespace std;
#define pb push_back
std::vector<int> construct_permutation(long long k)
{
k--;
vector<int> tab;
int cnt=0;
int mx=0;
for (int i = 62; i >= 0; --i)
{
while(mx==0&&k>=(1LL<<i)-1){
mx=i;
k-=(1LL<<i)-1;
tab.pb(i);
}
while(mx>0&&k>=(1LL<<(i))){
k-=(1LL<<(i));
tab.pb(i+1);
}
}
sort(tab.rbegin(),tab.rend());
vector<int> ans;
int j=1;
for (int i = 0; i < mx;++i)
{
ans.pb(tab.size()+i-1);
while(j<tab.size()&&mx-i==tab[j]){
ans.pb(tab.size()-j-1);
j++;
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |