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 <bits/stdc++.h>
using namespace std;
vector<int> construct_permutation(long long k){
vector<int> ans;
long long pow_2 = 1, exp_2 = 0, flag = 0, curr = 0;
while(pow_2 * 2 <= k) pow_2 *= 2, exp_2++;
for(int i = exp_2 - 1; i > -1; i--){
ans.push_back(curr++);
if((k >> i) & 1){
if(i and (k >> (i-1) & 1) and flag > 1) ans.push_back(curr++), ans.insert(ans.begin() + 2, curr++), i--;
else ans.insert(ans.begin(), curr++), flag++;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |