Submission #767172

#TimeUsernameProblemLanguageResultExecution timeMemory
767172Ahmed57Permutation (APIO22_perm)C++17
76.89 / 100
27 ms1052 KiB
#include <bits/stdc++.h>

using namespace std;
vector<int> construct_permutation(long long k){
    //0 1 2 3 4 5 6 7 8
    k--;
    vector<int> v;
    for(long long i = 0;i<50;i++){
        if((1LL<<i)<=k){
            k-=(1LL<<i);
            v.push_back(i);
        }
    }
    for(long long i = 50;i>=0;i--){
        while((1LL<<i)<=k){
            long long xd = i;
            for(int j = v.size()-1;j>=xd;j--){
                v[j]++;
            }
            v.push_back(i);
            k-=(1LL<<i);
        }
    }
    return v;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...