Submission #1199494

#TimeUsernameProblemLanguageResultExecution timeMemory
1199494user149Permutation (APIO22_perm)C++20
64.62 / 100
8 ms1600 KiB
#include<bits/stdc++.h>
#include "perm.h"
using namespace std;

using ll=long long;

vector<int> construct_permutation(ll k){
    k--;

    int n=0;
    for(int j=0;j<=60;j++){
        if(k & (1ll<<j)) n+=(j+1);
    }

    vector<int> ans;

    int cur=n-1;
    for(int j=0;j<=60;j++){
        if(k & (1ll<<j)){
            ans.push_back(cur);
            for(int i=cur-j;i<=cur-1;i++) ans.push_back(i);

            cur-=j;
            cur--;
        }
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...