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;
vector<int> construct_permutation(long long k)
{
vector<long long> logs;
int L = 0;
for(int i = 0; i < log(k+1) * 2; i ++){
if(pow(2, i) <= k) {
logs.push_back(pow(2, i));
L = i;
}
}
vector<int> res(L, 0);
k -= logs[logs.size()-1];
//int x = log(k+1) / log(2) + 1;
iota(res.begin(), res.end(), 0);
while(k > 0){
for(int i = logs.size() - 1; i >= 0; i --){
if(logs[i] <= k){
res.insert(res.begin() + i, L);
k -= logs[i];
break;
}
}
L += 1;
}
/*for(int i = 0; i < res.size(); i ++){
cout << res[i] << " ";
}*/
return res;
}
/*
g++ -std=gnu++17 -Wall -O2 -static -o perm grader.cpp perm.cpp
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |