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;
//Main function split it to #(2^k-1)
vector<long long int> split(long long int k){
vector<long long int> ans;
while(k){
//cout << k << " ";
long long int a = (long long int)log2(k+1);
ans.push_back(a);
k -= (long long int) pow(2,a)-1;
}
return ans;
}
vector<int> construct_permutation(long long int k)
{
k-=1;
vector<long long int> process = split(k);
long long int Count = 0;
for(long long int i:process){
Count+=i;
}
vector<int> s;
for(int i:process){
for(int j=Count-i;j<Count;j++){
s.push_back(j);
}
Count-=i;
}
return s;
}
/*
int main(){
//vector<int> answer = construct_permutation(3);
//for(int i:answer) cout << i << " ";
vector<int> answer = construct_permutation(1000);//split((long long int)1024*1024*1024*1024*1024*1024-1);
for(int i:answer) cout << i << " ";
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |