Submission #862471

#TimeUsernameProblemLanguageResultExecution timeMemory
862471JakobZorzPermutation (APIO22_perm)C++17
91.33 / 100
1 ms436 KiB
#include<iostream>
#include"perm.h"
using namespace std;
typedef long long ll;


vector<int>construct_permutation(ll k){
    int num_pow=2;
    while((1LL<<num_pow)<=k){
        num_pow++;
    }
    num_pow--;
    vector<int>res;
    k-=1LL<<num_pow;
    
    int curr=num_pow;
    for(int i=0;i<num_pow;i++)
        if(k&(1LL<<i))
            curr++;
    
    for(int i=0;i<num_pow;i++){
        if(k&(1LL<<i)){
            res.push_back(--curr);
        }
        res.push_back(i);
    }
    
    /*for(int i:res)
        cout<<i<<" ";
    cout<<"\n";*/
	return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...